-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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(v2): select correct tab when items are incorrectly ordered #4468
Conversation
[V1] Deploy preview failure Built without sensitive environment variables with commit a504a80 https://app.netlify.com/sites/docusaurus-1/deploys/60549e4053745d0008f2fcaf |
const handleTabChange = ( | ||
event: React.FocusEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>, | ||
) => { | ||
const selectedTab = event.currentTarget; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we actually wants to use currentTarget here, instead of target
In case if tab header is not simple element (eg. swizzled) this will stop working
target
: is the element that triggered the event (e.g., the user clicked on)
currentTarget
: is the element that the event listener is attached to.
https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
Deploy preview for docusaurus-2 ready! Built without sensitive environment variables with commit a504a80 |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4468--docusaurus-2.netlify.app/ |
const selectedTabIndex = tabRefs.indexOf(selectedTab); | ||
const selectedTabValue = children[selectedTabIndex].props.value; | ||
const selectedTabValue = values[selectedTabIndex].value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of checking childrens we should check values, this also solves crash with missing TabItem during development
Seems to work fine! thanks |
Motivation
fixes #4465
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
create md(x) file in project with
currently there is no component gallery or place where specific test can be added
simple regression test can be done by checking: https://deploy-preview-4468--docusaurus-2.netlify.app/docs/typescript-support