fix(v2): select correct tab when items are incorrectly ordered#4468
fix(v2): select correct tab when items are incorrectly ordered#4468slorber merged 1 commit intofacebook:masterfrom
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.
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 selectedTab = event.currentTarget; | ||
| const selectedTabIndex = tabRefs.indexOf(selectedTab); | ||
| const selectedTabValue = children[selectedTabIndex].props.value; | ||
| const selectedTabValue = values[selectedTabIndex].value; |
There was a problem hiding this comment.
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