Skip to content

Commit

Permalink
chore(navigation): focus callbacks trigger post-mutation (#1102)
Browse files Browse the repository at this point in the history
Moving the `onRouteFocus` callbacks post-mutation to ensure listeners
receive the correct state.
  • Loading branch information
hgray-instawork authored Feb 26, 2025
1 parent cfdd14f commit a71d09e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/components/hv-route/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,6 @@ function HvRouteFC(props: Types.Props) {

// Use the focus event to set the selected route
const unsubscribeFocus: () => void = nav.addListener('focus', () => {
if (navigationContext.onRouteFocus && props.route) {
navigationContext.onRouteFocus(props.route);
}
const navStateMutationsDelay =
navigationContext.experimentalFeatures?.navStateMutationsDelay || 0;
const updateRouteFocus = () => {
Expand All @@ -586,6 +583,9 @@ function HvRouteFC(props: Types.Props) {
navigationContext.entrypointUrl,
docContext?.setDoc,
);
if (navigationContext.onRouteFocus && props.route) {
navigationContext.onRouteFocus(props.route);
}
};
if (navStateMutationsDelay > 0) {
// The timeout ensures the processing occurs after the screen is rendered or shown
Expand Down

0 comments on commit a71d09e

Please sign in to comment.