-
Notifications
You must be signed in to change notification settings - Fork 227
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(tab): Set initial tabIndex state to -1 (#690) #691
Conversation
Codecov Report
@@ Coverage Diff @@
## rc0.11.0 #691 +/- ##
=========================================
Coverage 94.88% 94.88%
=========================================
Files 68 68
Lines 2853 2853
Branches 432 432
=========================================
Hits 2707 2707
Misses 50 50
Partials 96 96
Continue to review full report at Codecov.
|
}); | ||
|
||
test('sets the tabIndex to -1 if props.active is false on mount', () => { | ||
const wrapper = shallow(<Tab active={false} />); |
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.
Could we update this to set no active property instead of explicitly setting active={false}
? Will the test still pass?
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.
Typically with these props, it wouldn't be hard-coded. It would usually look more like:
<Tab active={this.state.active} />
In that case it is more helpful to have that prop explicitly defined like that. Otherwise removing it would look like:
const props = {};
if (this.state.active) {
props.active = true;
}
<Tab {...props} />
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.
Fair enough, thanks for explaining. My thinking was that removing the active={false}
prop tests that a Tab
has tab-index=-1
by default without the user providing any active prop. However, that's more a test of Component.defaultProps
working than of the change here.
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.
LGTM!
}); | ||
|
||
test('sets the tabIndex to -1 if props.active is false on mount', () => { | ||
const wrapper = shallow(<Tab active={false} />); |
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.
Fair enough, thanks for explaining. My thinking was that removing the active={false}
prop tests that a Tab
has tab-index=-1
by default without the user providing any active prop. However, that's more a test of Component.defaultProps
working than of the change here.
That totally makes sense...and I had a double take for a second :) |
Sets the initial state for the
tabIndex
the same way it is set foraria-selected
. If a tab is active then theactivate
method on the foundation will update this state on mount.