Skip to content

Fix onSelection bug #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ekilah
Copy link
Contributor

@ekilah ekilah commented Jul 8, 2021

Fixes #142

Props in react can change over time, so they should not be saved when a component first mounts and then never updated. This causes issues when you, say, have a dynamic callback in onSelection that changes over time. Without this change, this library was calling the old/outdated callback instead of the most recent one.

This is a quick and easy fix, though I imagine a better fix would involve rewriting more of the code here. I don't see any reason for this to be problematic though. I've used this in my own project where I observed the bug and this does resolve it.

This PR includes /dist which is built via npm run prePublishOnly && git add -f ./dist/, which we wouldn't include before merging this PR. But in order to use this fork/branch directly in package.json I believe this was necessary for now.

For anyone else wanting to use this fork to fix #142 before it is merged, you can use this line in your package.json:

"react-aria-menubutton": "https://github.com/MercuryTechnologies/react-aria-menubutton.git#fixOnSelectionBug",

@ekilah ekilah force-pushed the fixOnSelectionBug branch from 4adee66 to 8c74682 Compare July 8, 2021 23:54
Copy link
Collaborator

@shirshendubhowmick shirshendubhowmick left a comment

Choose a reason for hiding this comment

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

@ekilah Thanks for the PR.

The pr looks good.

However we do not want to make the dist the part of the codebase, since we are very active on releasing a new version on npm as soon as something significant gets merged.

Please remove the entire dist from the PR and will be happy to merge & release a new version.

@ekilah ekilah force-pushed the fixOnSelectionBug branch from 8c74682 to 69ee103 Compare July 10, 2021 15:45
@ekilah ekilah force-pushed the fixOnSelectionBug branch from 69ee103 to b696dc2 Compare July 10, 2021 15:47
@ekilah
Copy link
Contributor Author

ekilah commented Jul 10, 2021

@shirshendubhowmick yeah, like I mentioned in the PR desc I only did that so I could use the fork for myself until the PR was ready to merge 👍

I've removed it now, when you get a chance to review. Thanks!

@shirshendubhowmick shirshendubhowmick merged commit 8df7c9e into davidtheclark:master Jul 10, 2021
@ekilah ekilah deleted the fixOnSelectionBug branch November 20, 2021 21:51
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.

onSelection does not update
2 participants