Skip to content

Conversation

taysea
Copy link
Collaborator

@taysea taysea commented Jul 20, 2022

What does this PR do?

Improves tracking of active item. Previously we were keying off of activeIndex which doesn't always align with the elements index in the select options (because infinite scroll loads options in steps). Instead, we track the active value in a ref and focus that.

We only ever want one option to be highlighted at once. I've simplified the keyboardNavigation logic to more simply handle the trade off of keyboard and mouse movement.

In order for the underlying button to receive the theme.global.hover.background treatment correctly for both mouse interactions and keyboard interactions (the styling should be consistent regardless of if user is interacting via mouse or keyboard). Adjusted SelectOption styled component to apply this instead of relying on hoverIndicator (which would only apply on :hover).

The snapshot changes are related to the active styling being handled now by activeStyle as opposed to hoverStyle. The visual experience for the user remains unchanged.

Where should the reviewer start?

What testing has been done on this PR?

Tested with voice over and compared new behavior with behavior enhanced in #5934. All behavior is retained.

Previously flagged keyboard errors have been resolved.

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Closes #6208
Closes #6238
Closes #6248

Screenshots (if appropriate)

Do the grommet docs need to be updated?

No.

Should this PR be mentioned in the release notes?

Yes.

Is this change backwards compatible or is it a breaking change?

Backwards compatible.

@taysea taysea requested a review from halocline July 20, 2022 22:26
Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

The keyboard behavior seems off.

  • Go to 'many options' story.
  • Tab focus on input
  • Spacebar to open
  • Down arrow as far as you can
  • Active index gets stuck at Option 33 and then keyboard controls stop working

Alternatively:

  • Open drop with mouse
  • Scroll to index far down (e.g. 60)
  • Try using arrow keys

@ericsoderberghp ericsoderberghp dismissed their stale review July 20, 2022 22:58

pending testing

Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Functionality looks good, just want to chat through a couple items to see if we might be able to simplify a bit of the keyboard vs mouse interactions.

  • Fixes #6208 & #6238
  • Fixes a custom theme hover background state regression as well. #6248

Comment on lines 2021 to 2022
background-color: lightgreen;
color: #7D4CDB;
Copy link
Collaborator

Choose a reason for hiding this comment

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

NOTE: This snapshot change is result of restoration of functionality supporting theme.global.hover.background. This was missed in this previous snapshot change L2127.

Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Closes #6208, #6238, and #6248.

🙌

@@ -142,6 +142,8 @@ const plainStyle = (props) => css`

const activeButtonStyle = (props) => css`
${activeStyle}
${props.activeIndicator &&
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we're adding activeIndicator to Button? If so, I think we're missing typescript, propTypes, unit tests, etc. Also, I'm wondering why we need this at the Button API level. I would expect that the presence of the active property would be sufficient. In other words, if I indicate that a Button is active, then I would expect the Button to indicate that visually some how.

Copy link
Collaborator Author

@taysea taysea Jul 22, 2022

Choose a reason for hiding this comment

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

Details about isolated use in Select in the code comment here: https://github.com/grommet/grommet/pull/6243/files#r927979426

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

open to other ways of achieving the functionality, but the functionality is needed

@taysea taysea requested a review from ericsoderberghp July 25, 2022 16:56
@ericsoderberghp ericsoderberghp merged commit 35f3af3 into grommet:master Jul 25, 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
3 participants