FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: allow Menu to reopen when hide animation callback never fires by ErfanBagheri404 · Pull Request #5051 · callstack/react-native-paper · GitHub

fix: allow Menu to reopen when hide animation callback never fires - #5051

Open
ErfanBagheri404 wants to merge 3 commits into
callstack:mainfrom
ErfanBagheri404:fix/menu-cannot-reopen
Open

fix: allow Menu to reopen when hide animation callback never fires#5051
ErfanBagheri404 wants to merge 3 commits into
callstack:mainfrom
ErfanBagheri404:fix/menu-cannot-reopen

Conversation

Copy link
Copy Markdown

Fixes #4763

On React Native >= 0.80 the hide animation completion callback is not delivered, so prevRendered.current stayed true and the menu could never be shown again after being dismissed.

Reset prevRendered.current before starting the hide animation instead of in its completion callback.

On React Native >= 0.80 the hide animation completion callback is not
delivered, so prevRendered.current stayed true and the menu could never
be shown again after being dismissed.

Reset prevRendered.current before starting the hide animation instead of
in its completion callback.

Fixes callstack#4763
setRendered(false);
prevRendered.current = false;
focusFirstDOMNode(anchorRef.current);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I suppose, moving prevRendered.current = false before hide animation can introduce a race. if the menu closes while its opening animation is running, the interrupted opening callback can set this back to true, preventing the menu from reopening

could we handle interrupted opening & hiding animations using finished and add a test for quickly closing & reopening the menu?

}).start(({ finished }) => {
  if (!finished) {
    return;
  }
  setMenuLayout({ width: 0, height: 0 });
  setRendered(false);
  prevRendered.current = false;
  focusFirstDOMNode(anchorRef.current);
});

When the menu closes mid-opening animation, the interrupted callback
was setting prevRendered.current = true, blocking the next open.
Only set it when the animation finishes.

Addresses review comment on callstack#5051.

MikitasK left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @ErfanBagheri404 🙏
LGTM 👌
just one non-blocking suggestion: regression test covering close & reopen behavior would be helpful

Cover the scenario where the menu is dismissed then immediately
reopened. Without the prevRendered.current reset in hide(), the
interrupted opening animation callback could lock the menu closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Menu component closes and fails to open again on re-render

2 participants


Back | FazBrowse Home | New Git URL