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

[SelectInput] Add tabIndex prop #10345

Merged
merged 4 commits into from Feb 23, 2018
Merged

Conversation

aigoncharov
Copy link

@aigoncharov aigoncharov commented Feb 19, 2018

Closes #10344

@oliviertassinari oliviertassinari changed the title [Closes #10344] [Select] tabIndex is hardcoded and can not be changed [Select] tabIndex is hardcoded and can not be changed Feb 19, 2018
@oliviertassinari oliviertassinari added the component: select This is the name of the generic UI component, not the React module! label Feb 19, 2018
@aigoncharov
Copy link
Author

@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.

@oliviertassinari
Copy link
Member

it kind of seems like something pretty trivial and therefore unnecessary

And yet, it's not working with the latest release :).

@aigoncharov
Copy link
Author

@oliviertassinari it's not? I see only code coverage tests failing

Copy link
Member

@mbrookes mbrookes 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 your PR! Some suggested changes for consistency with other components. Please could you also add a test for this behaviour?

@@ -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
*/
Copy link
Member

@mbrookes mbrookes Feb 19, 2018

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 @ignoreed, since it's a standard DOM attribute (albeit being applied to a nested div), but also since this is an internal component.

/**
* Tab index of the component
*/
tabIndex: PropTypes.number,
Copy link
Member

@mbrookes mbrookes Feb 19, 2018

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]),

@@ -154,6 +154,7 @@ class SelectInput extends React.Component {
open: openProp,
readOnly,
renderValue,
tabIndex,
Copy link
Member

@mbrookes mbrookes Feb 19, 2018

Choose a reason for hiding this comment

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

tabIndex: tabIndexProp,

@@ -260,6 +261,11 @@ class SelectInput extends React.Component {

const MenuMinWidth = this.displayNode && !autoWidth ? this.displayNode.clientWidth : undefined;

let tabIndexFinal = tabIndex || 0;
Copy link
Member

@mbrookes mbrookes Feb 19, 2018

Choose a reason for hiding this comment

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

let tabIndex = tabIndexProp || 0;

if (disabled) {
tabIndexFinal = null;
}

Copy link
Member

Choose a reason for hiding this comment

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

-    if (disabled) {
-      tabIndexFinal = null;
-    }

@@ -276,7 +282,7 @@ class SelectInput extends React.Component {
}}
data-mui-test="SelectDisplay"
aria-pressed={open ? 'true' : 'false'}
tabIndex={disabled ? null : 0}
tabIndex={tabIndexFinal}
Copy link
Member

@mbrookes mbrookes Feb 19, 2018

Choose a reason for hiding this comment

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

tabIndex={disabled ? null : tabIndex}

@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Feb 19, 2018
@mbrookes mbrookes changed the title [Select] tabIndex is hardcoded and can not be changed [SelectInput] Add tabIndex prop Feb 19, 2018
@aigoncharov
Copy link
Author

@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!

@oliviertassinari oliviertassinari self-assigned this Feb 23, 2018
@oliviertassinari oliviertassinari added new feature New feature or request and removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants