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

TreeView: Align tree item toggle and visual icons to top of item #4572

Merged
merged 13 commits into from
May 20, 2024

Conversation

iansan5653
Copy link
Contributor

@iansan5653 iansan5653 commented May 8, 2024

The vast majority of the time, TreeView items are only one line and the content is truncated to fit. However, they can potentially wrap, as in https://github.com/github/collaboration-workflows-flex/issues/902 (internal issue). In this case, we want the chevron to still remain locked to the top of the item, rather than vertically centered.

This is slightly challenging because the height of items changes depending on the input mode, expanding automatically for touch controls. It wasn't complicated to move the min-height to a CSS variable and calculate a correct padding based on that: min-height / 2 - icon-height.

There is no visual change here for the non-wrapped item.

Changelog

New

Changed

  • Always align TreeView chevron icon to top of item

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@iansan5653 iansan5653 requested a review from a team as a code owner May 8, 2024 16:30
Copy link

changeset-bot bot commented May 8, 2024

🦋 Changeset detected

Latest commit: 39c1f6e

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

@iansan5653 iansan5653 changed the title Pin tree item toggle icon to top TreeView: Align tree item toggle icon to top of item May 8, 2024
@iansan5653 iansan5653 self-assigned this May 8, 2024
@iansan5653 iansan5653 added the component: TreeView Issues related to the TreeView component label May 8, 2024
Copy link
Contributor

github-actions bot commented May 8, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.53 KB (+0.04% 🔺)
packages/react/dist/browser.umd.js 88.84 KB (-0.01% 🔽)

Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

Hey @iansan5653 👋🏻 Thanks for the PR! Left a comment about horizontal centring. The rest of it looks good to me. We should also get a designer review on this though - tagging @mperrotti 🙌🏻

packages/react/src/TreeView/TreeView.tsx Show resolved Hide resolved
@mperrotti
Copy link
Contributor

@iansan5653 - can we add a story that demonstrates this change? Kind of like this...
Screenshot 2024-05-09 at 1 27 01 PM

Alternatively, we could update all existing stories to have an expandable node that has 2 lines of content. That seems unnecessary though...

Copy link
Contributor

github-actions bot commented May 9, 2024

Uh oh! @mperrotti, the image you shared is missing helpful alt text. Check #4572 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@iansan5653
Copy link
Contributor Author

Added a story. Now that I'm looking at it I'm thinking maybe we should top-align the leading and trailing visuals as well? I'm not totally sure how I feel about this approach given the leading/trailing visual appearance... maybe overriding the styling for the specific use case of sub-issues is actually better 🤔 But we don't have any official style overriding support, requiring us to reach in and select PRIVATE classes, which is hacky.

image

Copy link
Contributor

github-actions bot commented May 9, 2024

Uh oh! @iansan5653, the image you shared is missing helpful alt text. Check #4572 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@broccolinisoup
Copy link
Member

Added a story. Now that I'm looking at it I'm thinking maybe we should top-align the leading and trailing visuals as well? I'm not totally sure how I feel about this approach given the leading/trailing visual appearance... maybe overriding the styling for the specific use case of sub-issues is actually better 🤔 But we don't have any official style overriding support, requiring us to reach in and select PRIVATE classes, which is hacky.

It makes sense o me to align all to the top - not the same case but we took a similar approach for pageheader as well that we align all visuals to the top when the title is multiline

@mperrotti thoughts?

@iansan5653
Copy link
Contributor Author

It makes sense o me to align all to the top - not the same case but we took a similar approach for pageheader as well that we align all visuals to the top when the title is multiline

If that's the preferred approach I'd be happy to implement it 👍

@JelloBagel JelloBagel self-assigned this May 14, 2024
@JelloBagel JelloBagel requested a review from a team as a code owner May 16, 2024 17:55
@JelloBagel JelloBagel marked this pull request as draft May 16, 2024 18:00
@JelloBagel
Copy link
Contributor

JelloBagel commented May 16, 2024

I updated the leading/trailing visual to be top aligned as well: 185b613. I removed the min-height to properly align the visuals with the text but kept the same visual height by adding padding to the top and bottom of the text.

Storybook Preview

Edit: VRT in CI was failing so I added the update-snapshots label but the difference between the before and after looked nominal locally

Before After Diff
A file tree with one tree item highlighted A file tree with one tree item highlighted A overalyed comparison of the before and after file trees with red and yellow colors to indicate differences

@JelloBagel JelloBagel marked this pull request as draft May 16, 2024 19:00
@JelloBagel JelloBagel marked this pull request as ready for review May 16, 2024 19:00
Copy link
Contributor

Uh oh! @JelloBagel, the image you shared is missing helpful alt text. Check #4572 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@primer primer bot temporarily deployed to github-pages May 16, 2024 23:08 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4572 May 16, 2024 23:09 Inactive
@JelloBagel JelloBagel changed the title TreeView: Align tree item toggle icon to top of item TreeView: Align tree item toggle and visual icons to top of item May 17, 2024
Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

Hello! I left a few comments/questions. Let me know if there is anything I misunderstood or if there is anything I can clarify about my questions/comments 🙌🏻

packages/react/src/TreeView/TreeView.tsx Outdated Show resolved Hide resolved
packages/react/src/TreeView/TreeView.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@mperrotti mperrotti left a comment

Choose a reason for hiding this comment

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

These changes make sense and seem safe to me.

@JelloBagel JelloBagel added this pull request to the merge queue May 20, 2024
Merged via the queue into main with commit ac25029 May 20, 2024
30 checks passed
@JelloBagel JelloBagel deleted the treeview-top-align-toggle branch May 20, 2024 17:57
@primer primer bot mentioned this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TreeView Issues related to the TreeView component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants