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(listitem): allows optional change of role #723

Merged
merged 3 commits into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion react/src/lib/ListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class ListItem extends React.Component {
refName,
role,
separator,
specifyRoleWithoutList,
title,
type,
...props
Expand Down Expand Up @@ -309,7 +310,7 @@ class ListItem extends React.Component {
contextProps.type = type || (listContext && listContext.type);
contextProps.focus = focus || (listContext && listContext.focus === contextProps.uniqueKey);
contextProps.active = active || (listContext && listContext.active === contextProps.uniqueKey);
contextProps.role = (listContext && listContext.role) || role;
contextProps.role = specifyRoleWithoutList ? role : (listContext && listContext.role) || role;
contextProps.ariaConfig = listContext && listContext.ariaConfig;

return (
Expand Down Expand Up @@ -384,6 +385,9 @@ ListItem.propTypes = {
role: PropTypes.string,
/** @prop Prop that controls whether to show separator or not | false */
separator: PropTypes.bool,
/** @prop Prop that enables assigning role per listitem instead of the default provided by List context */
/** Allows Lists to have listitem with different roles */
specifyRoleWithoutList: PropTypes.bool,
/** @prop ListItem Title | '' */
title: PropTypes.string,
/** @prop ListItem size | '' */
Expand Down Expand Up @@ -427,6 +431,7 @@ ListItem.defaultProps = {
refName: 'navLink',
role: 'listitem',
separator: false,
specifyRoleWithoutList: false,
title: '',
type: '',
value: '',
Expand Down