Skip to content

Commit c1505ba

Browse files
charislamjoshenlim
andauthored
fix: table editor menu on mobile (supabase#38572)
* fix: table editor menu on mobile Problem: On mobile, when the schema selector is changed in the table editor menu, the menu immediately closes again before the user has a chance to select a table. Solution: The closing is caused by the new schema selection updating the router query. Whenever router.asPath changes, layout logic causes the mobile menu to collapse. This layout logic probably makes sense for the vast majority of cases, and I don't want to touch something that probably affects many screens, so I opted instead to change the schema selection locally within the TableEditorMenu. The schema selection on mobile is now a two-phase commit. In the first phase, only local schema state changes, so the user has time to select a table. When the user selects a table or closes the menu, the schema state is committed, which triggers the global state change, including the router query update. * Revert "fix: table editor menu on mobile" This reverts commit f883513. * fix: don't close mobile menu simply for query param changes --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent 0df17be commit c1505ba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/ui-patterns/src/MobileSheetNav/MobileSheetNav.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ const MobileSheetNav: React.FC<{
1616
const router = useRouter()
1717
const { width } = useWindowSize()
1818

19+
const pathWithoutQuery = router?.asPath?.split('?')?.[0]
1920
useEffect(() => {
2021
onOpenChange(false)
21-
}, [router?.asPath])
22+
}, [pathWithoutQuery])
2223

2324
useEffect(() => {
2425
onOpenChange(false)

0 commit comments

Comments
 (0)