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

Use floats to hide ActionBar items to address Android Chrome overflow issue #2425

Merged
merged 5 commits into from
Dec 7, 2023

Conversation

camertron
Copy link
Contributor

@camertron camertron commented Dec 4, 2023

What are you trying to accomplish?

This PR is attempting to address an issue mostly occurring on older Android phones where the container around ActionBar icon buttons does not resize properly on smaller screens and "squashes" the rest of the content to the left-hand side of the page:

Screenshots

Before After
A screenshot of Chrome running on a Galaxy A10 phone via Browserstack. A GitHub issue is displayed in the browser. Most of the page's content appears squished to the left-hand side. A series of icons above the comment text area appears to be the culprit, as they are the only bits of UI that stretch all the way to the right-hand side. A screenshot of Chrome running on a Galaxy A10 phone via Browserstack. A GitHub issue is displayed in the browser. The page looks normal, with no content squishing or overflow issues visible.

Integration

No updates required in production.

List the issues that this change affects.

Fixes: https://github.com/github/primer/issues/2859
Fixes: https://github.com/github/primer/issues/2891

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

The ActionBar component currently hides/shows items based on the amount of available horizontal space. Unfortunately such calculations are semi error-prone because padding, margin, and the presence of dividers must be taken into account, which is difficult to get right. This PR removes the width calculation logic and instead uses a container <div> with a fixed height and floated icon buttons. As the div shrinks, items are automatically wrapped to the next line. These items become invisible because of the container's fixed height. On each resize event, JavaScript loops over each item and compares its top to the first item's top. If greater, the element has wrapped to the next line and should be hidden. The corresponding menu item should be un-hidden. As the container grows, the process is done in reverse, showing items and hiding menu items.

Anything you want to highlight for special attention from reviewers?

This is probably the first time I've ever wanted floated elements to wrap lol.

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • 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.

Copy link

changeset-bot bot commented Dec 4, 2023

🦋 Changeset detected

Latest commit: 49186b9

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

This PR includes changesets to release 1 package
Name Type
@primer/view-components 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 github-actions bot added javascript Pull requests that update Javascript code ruby Pull requests that update Ruby code css Pull requests that update CSS code labels Dec 4, 2023
@camertron camertron mentioned this pull request Dec 4, 2023
10 tasks
@camertron camertron force-pushed the action_bar_overflow_hidden branch from 7ea55fc to 49e3732 Compare December 4, 2023 22:29
@github-actions github-actions bot added patch release and removed ruby Pull requests that update Ruby code labels Dec 4, 2023
@camertron camertron marked this pull request as ready for review December 5, 2023 21:36
@camertron camertron requested a review from a team as a code owner December 5, 2023 21:36
@camertron camertron requested review from a team, tobiasahlin and jonrohan December 5, 2023 21:36
Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

👏🏻 Honestly shocked that you were able to reduce this code so much with floats. I'm trying to think of problems with doing it this way but not sure if there are any. Would be interested in seeing it in some dotcom review lab situations.

@langermank can you think of anything that I might be overlooking?

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

Agree with @jonrohan we should test this on a lab in dotcom just to be sure 👍

@camertron camertron merged commit 65f418f into main Dec 7, 2023
34 checks passed
@camertron camertron deleted the action_bar_overflow_hidden branch December 7, 2023 18:19
@primer primer bot mentioned this pull request Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css Pull requests that update CSS code javascript Pull requests that update Javascript code patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants