-
Notifications
You must be signed in to change notification settings - Fork 471
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
Conversation
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.
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]} |
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.
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]} |
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.
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}`} |
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.
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]} |
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.
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]} |
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.
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}`} |
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.
Use getter
{selectAllLabel && ( | ||
<li | ||
key={selectAllLabel} | ||
className={`${ | ||
this.state.currentValue === selectAllLabel ? 'active' : '' | ||
}`} | ||
role="radio" | ||
aria-checked={this.state.currentValue === selectAllLabel} |
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.
You can use getter here too.
Sure I will do these changes. |
No description provided.