Skip to content
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

Fix position of choices container when input element moves to another location #2860

Merged
merged 3 commits into from
Feb 21, 2019

Conversation

tiagoschenkel
Copy link
Contributor

This merge request solves the problem reported in issue #2259.

The problem happens because the Popper component used to render the choices is a stateless component. Since the Popper component receives a reference to the inputEl component, the render method is unable to detect when the original inputEl moved to another place.

I noticed that when the original input element moves, React is keeping the old Popper component without forcing it to redraw.

My solution is based on this example from Material-UI docs:
https://v1-5-0.material-ui.com/utils/popper/#faked-reference-object

I'm keeping an object that has a reference to the last position of the inputEl and updating this object only when the inputEl moves. Doing this we only force the redraw of the Popper container only when needed.

Fixes #2259.

Copy link
Collaborator

@djhi djhi left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks!

@djhi djhi added this to the 2.7.2 milestone Feb 21, 2019
@djhi djhi merged commit be20c55 into marmelab:master Feb 21, 2019
@tiagoschenkel tiagoschenkel deleted the issue-2259 branch February 21, 2019 19:27
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.

2 participants