Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,21 +364,21 @@
});
}, [anchor, attachListeners, measureAnchorLayout, theme]);

const hide = React.useCallback(() => {
const hide = React.useCallback((focus = true) => {

Check failure on line 367 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎····`
removeListeners();

Check failure on line 368 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`

const { animation } = theme;

Check failure on line 370 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `····` with `······`

Animated.timing(opacityAnimationRef.current, {

Check failure on line 372 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
toValue: 0,

Check failure on line 373 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
duration: ANIMATION_DURATION * animation.scale,

Check failure on line 374 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
easing: EASING,

Check failure on line 375 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
useNativeDriver: true,

Check failure on line 376 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
}).start(() => {

Check failure on line 377 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
setMenuLayout({ width: 0, height: 0 });

Check failure on line 378 in src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
setRendered(false);
prevRendered.current = false;
focusFirstDOMNode(anchorRef.current);
if (focus) { focusFirstDOMNode(anchorRef.current) };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

on a quick open and close, the focus could be lost:

  • menu is opened
  • then closed before open animation finishes
  • both hide and show animation callbacks run
  • since prevRendered.current is read before hide starts and stops the animation, it won't reflect the change to prevRendered.current = true in the show callback, using old value for show

we should check for finished in the animation callbacks to avoid changing focus when animation is interrupted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See my comment on the AI review regarding the +quick open and close+.

I currently don't have any bandwidth to update this PR, but I left "edits allowed from maintainers" checked, so someone can take it over.

});
}, [removeListeners, theme]);

Expand All @@ -393,7 +393,7 @@
}

if (!display) {
hide();
hide(prevRendered.current);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If the animation is interrupted, the callback should not run. If the callback still runs on an interrupted animation, that's a separate bug unrelated to this PR and should be solved in a different PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll leave this one for someone at the company who can take over this PR. It's impossible to run this repository on my windows machine, so cannot run the tests locally nor develop.

}

return;
Expand Down
Loading