Skip to content

Commit

Permalink
Merge pull request #791 from ibi-group/deselect-all-mode-button-enhan…
Browse files Browse the repository at this point in the history
…cements

fix(trip-form): close mode button before setting submode options to default
  • Loading branch information
josh-willis-arcadis authored Nov 13, 2024
2 parents 125ed0c + e1cd4de commit f22594c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export default function SubSettingsPane({

const handleSettingChange = useCallback(
(setting: ModeSetting) => (evt: QueryParamChangeEvent) => {
let time = 0;
// check if setting is a transport mode setting
if (settingsWithTransportMode.find(s => s.key === setting.key)) {
// check if all submodes are disabled
Expand All @@ -210,10 +211,14 @@ export default function SubSettingsPane({
evt[s.key] = Object.keys(evt).includes(s.key) || !s.value;
});
onAllSubmodesDisabled(modeButton);
time = 700;
}
}

onSettingUpdate(evt);
setTimeout(() => {
// This is a hack to make sure the setting is updated before the next render
onSettingUpdate(evt);
}, time);
},
[onSettingUpdate]
);
Expand Down

0 comments on commit f22594c

Please sign in to comment.