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

fix: useTag hook #7394

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

fix: useTag hook #7394

wants to merge 4 commits into from

Conversation

minzzang144
Copy link

Closes #7080

✅ 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:

🧢 Your Project:

},
rowProps: mergeProps(rowProps, domProps, linkProps, {
tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,
tabIndex: getTabIndex(isDisabled, isFocused, isNonFocused),
Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the opportunity to resolve this issue.
I solved an issue where the TabGroup component was deleted when it was disalbed.
I don't think it's a good code, but if there is a better code or something wrong, please point it out. thanks!

@minzzang144 minzzang144 reopened this Nov 19, 2024
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. It looks like you've run prettier or something equivalent over the file. Would you mind undoing that so that we can review the actual change? right now there is a bunch of noise and things that will fail our lint. Thanks again!

@minzzang144
Copy link
Author

@snowystinger Thank you for your help. Edit completed!

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

Thanks for the quick update!

Would you mind adding a test for this?

Comment on lines +88 to +99
let isNonFocused = state.selectionManager.focusedKey == null;
function getTabIndex(
isDisabled: boolean,
isFocused: boolean,
isNonFocused: boolean
) {
if (isDisabled) {
return -1;
}
return isFocused || isNonFocused ? 0 : -1;
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let isNonFocused = state.selectionManager.focusedKey == null;
function getTabIndex(
isDisabled: boolean,
isFocused: boolean,
isNonFocused: boolean
) {
if (isDisabled) {
return -1;
}
return isFocused || isNonFocused ? 0 : -1;
}
let tabIndex = -1;
f (!isDisabled && (isFocused || state.selectionManager.focusedKey == null)) {
tabIndex = 0;
}

We can just derive it as part of render, no need to add an additional function call with arguments we already have.

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.

Disabled Tag can be removed with keyboard nav
2 participants