From 8c74d29cb0151eabb56dad05f63f2b0dbaca5465 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:38:32 -0500 Subject: [PATCH 1/2] fix(subsettingspane): use setTimeout to close mode button before setting submodes back to defaults --- .../trip-form/src/MetroModeSelector/SubSettingsPane.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx b/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx index 43c79e904..869755a07 100644 --- a/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx +++ b/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx @@ -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 @@ -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] ); From e1cd4deb6e91e05cefea6bf48715462b25884932 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:51:17 -0600 Subject: [PATCH 2/2] refactor(sub-settings-pane): increase timeout time to match storybook animation --- packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx b/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx index 869755a07..8778cc11a 100644 --- a/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx +++ b/packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx @@ -211,7 +211,7 @@ export default function SubSettingsPane({ evt[s.key] = Object.keys(evt).includes(s.key) || !s.value; }); onAllSubmodesDisabled(modeButton); - time = 500; + time = 700; } }