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

feat: accessibility enhancements in list components #1041

Merged
merged 3 commits into from
Aug 5, 2019
Merged

Conversation

jyash97
Copy link
Contributor

@jyash97 jyash97 commented Jul 10, 2019

No description provided.

@jyash97 jyash97 requested review from lakhansamani and bietkul July 10, 2019 10:47
Copy link
Contributor

@bietkul bietkul left a comment

Choose a reason for hiding this comment

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

I can see a lot of code duplication when computing the conditions.
It'll be better if can refactor it out.

{selectAllLabel ? (
<li
key={selectAllLabel}
className={`${
this.state.currentValue[selectAllLabel] ? 'active' : ''
}`}
role="option"
aria-checked={!!this.state.currentValue[selectAllLabel]}
aria-selected={!!this.state.currentValue[selectAllLabel]}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid code duplication, Can you keep a variable to store !!this.state.currentValue[selectAllLabel], and use it further.

@@ -469,13 +477,16 @@ class MultiDataList extends Component {
className={`${
this.state.currentValue[item.label] ? 'active' : ''
}`}
role="option"
aria-checked={!!this.state.currentValue[item.label]}
aria-selected={!!this.state.currentValue[item.label]}
Copy link
Contributor

Choose a reason for hiding this comment

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

same goes for it.

>
<Checkbox
className={
getClassName(this.props.innerClass, 'checkbox') || null
}
id={`${this.props.componentId}-${item.label}`}
name={this.props.componentId}
name={`${this.props.componentId}-${item.label}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use getter to compute the values.

{selectAllLabel ? (
<li
key={selectAllLabel}
className={`${
this.state.currentValue[selectAllLabel] ? 'active' : ''
}`}
role="option"
aria-checked={!!this.state.currentValue[selectAllLabel]}
aria-selected={!!this.state.currentValue[selectAllLabel]}
Copy link
Contributor

Choose a reason for hiding this comment

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

avoid duplication

@@ -570,13 +576,16 @@ class MultiList extends Component {
className={`${
this.state.currentValue[item.key] ? 'active' : ''
}`}
role="option"
aria-checked={!!this.state.currentValue[item.key]}
aria-selected={!!this.state.currentValue[item.key]}
Copy link
Contributor

Choose a reason for hiding this comment

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

avoid duplication

>
<Checkbox
className={
getClassName(this.props.innerClass, 'checkbox') || null
}
id={`${this.props.componentId}-${item.key}`}
name={this.props.componentId}
name={`${this.props.componentId}-${item.key}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use getter

{selectAllLabel && (
<li
key={selectAllLabel}
className={`${
this.state.currentValue === selectAllLabel ? 'active' : ''
}`}
role="radio"
aria-checked={this.state.currentValue === selectAllLabel}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use getter here too.

@jyash97
Copy link
Contributor Author

jyash97 commented Jul 10, 2019

Sure I will do these changes.

@bietkul bietkul merged commit 95ae858 into next Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants