Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[A11y] [Header] Fix search bar element focus order (@W-12627142@) #1969

Merged
merged 5 commits into from
Aug 9, 2024

Conversation

adamraya
Copy link
Collaborator

@adamraya adamraya commented Aug 8, 2024

Description

Redo of PR #1910 with an isomorphic solution.

Fixes the search bar element in the header to the correct keyboard focus order for Desktop and Mobile, left to right and top to bottom.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Isomorphic fix focus order of the header search bar.

How to Test-Drive This PR

  1. Checkout this branch a11y-header-order-focus-ssr and start the retail react app npm start
  2. Click on the header and press the tab key to move the focus to the different elements in the header.
  3. Verify the tab focus order follows the expected left to right, top to bottom.
  4. Verify the are no render issues server/client http://localhost:3000/?__server_only

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@adamraya adamraya requested a review from a team as a code owner August 8, 2024 23:27
packages/template-retail-react-app/CHANGELOG.md Outdated Show resolved Hide resolved
@@ -318,6 +339,9 @@ const Header = ({
{...styles.icons}
onClick={onMyCartClick}
/>
<HideOnDesktop display={{base: 'contents', lg: 'none'}}>
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 what does display: contents do?

It actually got replaced by another more-specific css selector. So display: none is what actually got used.

Arc 2024-08-09 at 10 24 02

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's the expected behavior on the desktop screen. Check the styles used on mobile, and you'll see display: contents on mobile.

*/
export const HideOnDesktop = ({children}) => (
<Box display={{base: 'block', lg: 'none'}}>{children}</Box>
export const HideOnDesktop = ({children, display = {base: 'block', lg: 'none'}}) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to make it more general, we can have the user override any props. Something like this:

export const HideOnDesktop = ({children, ...rest}) => (
    <Box display={{base: 'block', lg: 'none'}} {...rest}>
        {children}
    </Box>
)

joeluong-sfcc
joeluong-sfcc previously approved these changes Aug 9, 2024
Copy link
Contributor

@vmarta vmarta left a comment

Choose a reason for hiding this comment

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

Just comments re: the prop types.

@adamraya adamraya merged commit adbe1ad into develop Aug 9, 2024
29 checks passed
@adamraya adamraya deleted the a11y-header-order-focus-ssr branch August 9, 2024 22:01
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants