Skip to content

Conversation

@colebemis
Copy link
Contributor

@colebemis colebemis commented Oct 20, 2022

Properly handles the "scroll into view" behavior when focus moves between TreeView items.

Before

Notice how the scroll jumps when focus moves to a directory with lots of items:

CleanShot.2022-10-20.at.16.16.24.mp4

After

CleanShot.2022-10-20.at.16.10.44.mp4

Closes https://github.com/github/primer/issues/1432

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2022

🦋 Changeset detected

Latest commit: 1ea16d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 78.12 KB (+0.17% 🔺)
dist/browser.umd.js 78.77 KB (+0.18% 🔺)

@colebemis colebemis temporarily deployed to github-pages October 20, 2022 23:11 Inactive
@colebemis colebemis marked this pull request as ready for review October 20, 2022 23:20
@colebemis colebemis requested review from a team and josepmartins October 20, 2022 23:20
@colebemis colebemis temporarily deployed to github-pages October 20, 2022 23:26 Inactive
onKeyDown={handleKeyDown}
onFocus={event => {
// Scroll the first child into view when the item receives focus
event.currentTarget.firstElementChild?.scrollIntoView({block: 'nearest', inline: 'nearest'})
Copy link
Member

Choose a reason for hiding this comment

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

Ooo, love the firstElementChild usage ✨

@colebemis colebemis temporarily deployed to github-pages October 24, 2022 21:03 Inactive
@colebemis colebemis temporarily deployed to github-pages October 24, 2022 22:06 Inactive
@colebemis colebemis temporarily deployed to github-pages October 24, 2022 23:12 Inactive
@colebemis colebemis temporarily deployed to github-pages October 24, 2022 23:21 Inactive
@colebemis colebemis merged commit d68f5ff into main Oct 24, 2022
@colebemis colebemis deleted the treeview-fix-focus-scroll branch October 24, 2022 23:24
@primer-css primer-css mentioned this pull request Oct 24, 2022
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.

4 participants