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
[SelectInput] Add tabIndex prop #10345
Conversation
@oliviertassinari Do you want me to add any tests? I thought about having a test about passing a tabIndex and then checking that it's there indeed, but it kind of seems like something pretty trivial and therefore unnecessary. |
And yet, it's not working with the latest release :). |
@oliviertassinari it's not? I see only code coverage tests failing |
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.
Thanks for your PR! Some suggested changes for consistency with other components. Please could you also add a test for this behaviour?
src/Select/SelectInput.js
Outdated
@@ -413,6 +419,10 @@ SelectInput.propTypes = { | |||
* You can only use it when the `native` property is `false` (default). | |||
*/ | |||
renderValue: PropTypes.func, | |||
/** | |||
* Tab index of the component | |||
*/ |
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.
This prop can probably be @ignore
ed, since it's a standard DOM attribute (albeit being applied to a nested div), but also since this is an internal component.
src/Select/SelectInput.js
Outdated
/** | ||
* Tab index of the component | ||
*/ | ||
tabIndex: PropTypes.number, |
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.
It should also accept a string. You can follow the Chip
example:
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
src/Select/SelectInput.js
Outdated
@@ -154,6 +154,7 @@ class SelectInput extends React.Component { | |||
open: openProp, | |||
readOnly, | |||
renderValue, | |||
tabIndex, |
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.
tabIndex: tabIndexProp,
src/Select/SelectInput.js
Outdated
@@ -260,6 +261,11 @@ class SelectInput extends React.Component { | |||
|
|||
const MenuMinWidth = this.displayNode && !autoWidth ? this.displayNode.clientWidth : undefined; | |||
|
|||
let tabIndexFinal = tabIndex || 0; |
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.
let tabIndex = tabIndexProp || 0;
src/Select/SelectInput.js
Outdated
if (disabled) { | ||
tabIndexFinal = null; | ||
} | ||
|
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.
- if (disabled) {
- tabIndexFinal = null;
- }
src/Select/SelectInput.js
Outdated
@@ -276,7 +282,7 @@ class SelectInput extends React.Component { | |||
}} | |||
data-mui-test="SelectDisplay" | |||
aria-pressed={open ? 'true' : 'false'} | |||
tabIndex={disabled ? null : 0} | |||
tabIndex={tabIndexFinal} |
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.
tabIndex={disabled ? null : tabIndex}
@mbrookes sure. I'll make these changes, though it's gonna take couple days to find a time slot for this. Thanks for the review! |
5863733
to
e5e35a8
Compare
e5e35a8
to
58c4a61
Compare
58c4a61
to
df3fe0f
Compare
Closes #10344