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

amitha/fix/text-field-focus-animation-in-dialog #333

Merged
merged 4 commits into from
Nov 15, 2021

Conversation

amit-hanoch
Copy link
Contributor

@amit-hanoch amit-hanoch commented Nov 15, 2021

When autofocus in dialog and scrolling to the bottom of the screen the screen "jumps" because the focus collides with the scroll to, adding requestAnimationFrame is the solution.

Read about it a little bit and a lot of UI libraries like material-ui use setTimeout 0 to solve this issue and it's pretty common so I think we need to make sure all .focus() to happen with request animation frame from now on.

Updating existing component

Basic

  • PR has description
  • Changes to the component are backward compatible (including selectors structure). If not - add to the title of the PR "BREAKABLE_CHANGE""
  • All changes to the component are reflected in the ReadMe
  • If component is old and was not compliant with the latest guidelines - it was fixed (optional)

Style

Storybook

  • All the changes to the component should be reflected in the Storybook.
  • Component passed Accessibility Plugin checks

Tests

  • All current tests are passing
  • New functionality is covered with tests
  • Tests are compliant with TESTING_README.md instructions

@amit-hanoch amit-hanoch changed the title move autofocus to useEffect with request animation frame amitha/fix/text-field-focus-animation-in-dialog Nov 15, 2021
@@ -104,6 +105,12 @@ const TextField = forwardRef(
elementType: "div"
});

useEffect(() => {
if (inputRef.current && autoFocus) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add cancelAnimationFrame on the return function of the useEffect please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orrgottlieb found that i missed combo aswell please look there too :)

@orrgottlieb orrgottlieb merged commit d1b0c8a into master Nov 15, 2021
@orrgottlieb orrgottlieb deleted the amitha/fix/text-field-focus-animation-in-dialog branch November 15, 2021 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants