-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[MM-13298] Remove usage of localizeMessage for aria-label and title attributes #2245
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.
Thanks @kosgrz, looks good to me. Just one small comment re: one missed localizeMessage.
Also, looks like we can have a collection of icons, like below to name a few:
- Success Icon
- Reload Icon
- Collapse Icon
- Loading Icon
- Warning Icon
That might be good to have here, or a separate PR will do as well.
Thanks for the review @saturninoabril.
I don't know I understand correctly. Do you mean I should extract these icons to separate components and use them in proper places? So for example if I have this code fragment in if (this.state.showWarning) {
warning = (
<div
style={style.warning}
className='alert alert-warning'
>
<FormattedMessage
id='generic_icons.warning'
defaultMessage='Warning Icon'
>
{(title) => (
<i
className='fa fa-warning'
title={title}
/>
)}
</FormattedMessage>
<FormattedMarkdownMessage
id='admin.cluster.should_not_change'
defaultMessage='WARNING: These settings may...'
/>
</div>
);
} I instead should extract export default class WarningIcon extends React.PureComponent {
render() {
return (
<FormattedMessage
id='generic_icons.warning'
defaultMessage='Warning Icon'
>
{(title) => (
<i
className='fa fa-warning'
title={title}
/>
)}
</FormattedMessage>
);
}
} and use it in if (this.state.showWarning) {
warning = (
<div
style={style.warning}
className='alert alert-warning'
>
<WarningIcon/>
<FormattedMarkdownMessage
id='admin.cluster.should_not_change'
defaultMessage='WARNING: These settings may...'
/>
</div>
);
} Is my understanding correct? |
@kosgrz Yes, that's exactly. Maybe create a folder like UPDATE: I'll bring up first the case of moving other components from |
I agree that we can move the other icons later. It probably makes sense to consolidate them, but I think it's fine leaving them where they are for now |
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 @kosgrz, all are good to me except to last comments on function binding and snapshot tests for new icon components.
@@ -45,6 +46,8 @@ export default class AddUsersToTeam extends React.Component { | |||
addError: null, | |||
loadingUsers: true, | |||
}; | |||
|
|||
this.renderOption = this.renderOption.bind(this); |
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.
In case this needs to bind, instead of adding above line you may convert the function into arrow function.
renderOption = (option, isSelected, onAdd) => {...}
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 the notice. I forgot about this benefit of arrow functions when I was writing this code. Nevertheless, this line is now unnecessary since I use just the AddIcon
component inside renderOption
instead of this.context.intl.formatMessage
and I don't need to have access to this
. I deleted this line in the last update of this PR.
> | ||
{(title) => ( | ||
<span | ||
className='fa fa-angle-down header-dropdown__icon' |
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.
No action for now.
In the future, this needs to update once our UI come up with the standard dropdown icon of either fa-chevron-down or fa-angle-down.
…ttributes * Remove usage of localizeMessage for aria-label and title attributes in HTML tags * Remove duplicate tooltip caused by the usage of OverlayTrigger and title attribute
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 @kosgrz for your contribution!
Summary
Remove usage of localizeMessage for aria-label and title attributes in HTML tags. Remove duplicate tooltip caused by the usage of OverlayTrigger and title attribute.
Ticket Link
Jira ticket | GitHub Issue #9948
Checklist
make check-style
to check for style errors (required for all pull requests)make test
to ensure unit and component tests passed