Skip to content

Commit

Permalink
fix: close overlay drawer on click (#19984) (#20015)
Browse files Browse the repository at this point in the history
* fix: close overlay drawer on click

Close the overlay drawer
even when clicking on
same link and no actual
navigation happens.

Fixes #19823

* reset fromAnchor for navigation

This in case the flag has
for some reason not been
reset after a click.

Co-authored-by: caalador <[email protected]>
  • Loading branch information
vaadin-bot and caalador authored Sep 20, 2024
1 parent d22320e commit ebea4d6
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ function Flow() {
// in order to get a server round-trip even when navigating to the same URL again
fromAnchor.current = true;
navigate(path);
// Dispatch close event for overlay drawer on click navigation.
window.dispatchEvent(new CustomEvent('close-overlay-drawer'));
}, [navigate]);

const vaadinRouterGoEventHandler = useCallback((event: CustomEvent<URL>) => {
Expand All @@ -255,6 +257,7 @@ function Flow() {
const vaadinNavigateEventHandler = useCallback((event: CustomEvent<{state: unknown, url: string, replace?: boolean, callback: boolean}>) => {
const path = '/' + event.detail.url;
navigated.current = !event.detail.callback;
fromAnchor.current = false;
navigate(path, { state: event.detail.state, replace: event.detail.replace});
}, [navigate]);

Expand Down

0 comments on commit ebea4d6

Please sign in to comment.