Skip to content

Commit

Permalink
fix(subsettingspane): use setTimeout to close mode button before sett…
Browse files Browse the repository at this point in the history
…ing submodes back to defaults
  • Loading branch information
josh-willis-arcadis committed Oct 22, 2024
1 parent 1feb8f4 commit 8c74d29
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 = 500;
}
}

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 8c74d29

Please sign in to comment.