Skip to content

TagGroup: Add useTagGroupState and fix focus issues#3798

Merged
reidbarber merged 53 commits into
mainfrom
add-useTagGroupState-fix-focus
Jan 3, 2023
Merged

TagGroup: Add useTagGroupState and fix focus issues#3798
reidbarber merged 53 commits into
mainfrom
add-useTagGroupState-fix-focus

Conversation

@reidbarber
Copy link
Copy Markdown
Member

@reidbarber reidbarber commented Nov 29, 2022

Closes #3070, #3074

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Open the TagGroup -> onRemove story. After removing a tag, focus should go to the next tag (or previous tag if no next tag) and you should still be able to keyboard navigate between tags using arrow keys.

🧢 Your Project:

@adobe-bot
Copy link
Copy Markdown

@reidbarber reidbarber changed the title WIP: TagGroup: Add useTagGroupState and fix focus issues TagGroup: Add useTagGroupState and fix focus issues Nov 29, 2022
@adobe-bot
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Some typing suggestions/questions + a behavior change suggestion

Comment thread packages/@react-aria/tag/intl/en-US.json Outdated
Comment thread packages/@react-aria/tag/src/useTag.ts Outdated
Comment thread packages/@react-spectrum/tag/src/Tag.tsx Outdated
Comment thread packages/@react-stately/tag/src/useTagGroupState.ts Outdated
@adobe-bot
Copy link
Copy Markdown

@adobe-bot
Copy link
Copy Markdown

@reidbarber
Copy link
Copy Markdown
Member Author

snowystinger
snowystinger previously approved these changes Dec 19, 2022
ktabors
ktabors previously approved these changes Dec 20, 2022
Copy link
Copy Markdown
Collaborator

@ktabors ktabors left a comment

Choose a reason for hiding this comment

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

The testing says "previous" tag the code in stately says "next", unless there is no "next" then it is "previous".

Comment thread packages/@adobe/spectrum-css-temp/components/tags/index.css
Comment thread packages/@react-aria/tag/src/TagKeyboardDelegate.ts
focusMode: 'cell'
}, state, tagRef);
// We want the group to handle keyboard navigation between tags.
delete rowProps.onKeyDownCapture;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rowProps.onKeyDownCapture is set in useGridListItem as onKeyDown(). I was wondering if this should be a replace with the onKeyDown you're defining and not a delete, but nothing consuming this will call onKeyDownCapture, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could set it to undefined down there, but it would do the same thing. And I think we want onKeyDown here, we're just removing that handler since it would handle focusing within a cell, which we don't want.

@reidbarber reidbarber dismissed stale reviews from ktabors and snowystinger via d13c41c December 20, 2022 19:26
majornista
majornista previously approved these changes Dec 20, 2022
snowystinger
snowystinger previously approved these changes Dec 20, 2022
@reidbarber reidbarber requested a review from LFDanLu December 20, 2022 22:37
LFDanLu
LFDanLu previously approved these changes Dec 21, 2022
Copy link
Copy Markdown
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Just a couple of things of small things I noticed on this final pass but def can handle in a followup instead

*/

export type {AriaGridListProps, GridListProps} from '@react-aria/gridlist';
export type {ListState} from '@react-stately/list';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The exports here for AriaGridListProps, GridListProps, and SpectrumListViewProps were kept in here to preserve back compat, but these props are now exported from their specific packages. IMO we can go ahead and just export ListState from @react-stately/list if needed, where did you need this type specifically?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, I went ahead and removed this export

let onRemove = (key) => {
// If a tag is removed, restore focus to the tag after, or tag before if no tag after.
let restoreKey = state.collection.getKeyAfter(key) || state.collection.getKeyBefore(key);
state.selectionManager.setFocusedKey(restoreKey);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can be follow up, but I just noticed that focus seems to be lost when deleting a tag via TalkBack, not sure why that is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can investigate in a follow-up before release.

@reidbarber reidbarber dismissed stale reviews from LFDanLu, snowystinger, and majornista via aec919e January 3, 2023 19:01
Copy link
Copy Markdown
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

LGTM

@reidbarber reidbarber merged commit 9aa0c7e into main Jan 3, 2023
@reidbarber reidbarber deleted the add-useTagGroupState-fix-focus branch January 3, 2023 22:58
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.

Refactor TagGroup to focus row instead

6 participants