-
Notifications
You must be signed in to change notification settings - Fork 14
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(PPDSC-2403): Extend role and aria-haspopup on Popover #381
feat(PPDSC-2403): Extend role and aria-haspopup on Popover #381
Conversation
You can preview these changes on: |
src/popover/popover.tsx
Outdated
@@ -122,7 +123,7 @@ const ThemelessPopover = React.forwardRef<HTMLDivElement, PopoverProps>( | |||
buildRefElAriaAttributes={buildContextAriaAttributes} | |||
buildFloatingElAriaAttributes={buildFloatingElementAriaAttributes} | |||
useInteractions={useInteractions} | |||
role="dialog" | |||
role={role} |
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.
src/popover/popover.tsx
Outdated
@@ -28,7 +28,7 @@ import {filterOutFalsyProperties} from '../utils/filter-object'; | |||
const buildContextAriaAttributes: BuildAriaAttributesFn = ({ | |||
floating: {id, open}, | |||
}) => ({ | |||
'aria-haspopup': 'dialog', | |||
// 'aria-haspopup': 'dialog', |
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 don't have to remove that, this should stay as the default behaviour.
but we need to check if people provide they aria-haspopup and if so we don't apply it automatically.
For example:
<Popover content="..." role="menu">
<IconButton aria-haspopup="true" />
</Popover>
That logic should happen in base-floating-element.tsx file, at the point you are cloning the children you can check if the children have already aria-popup
src/popover/popover.tsx
Outdated
@@ -27,8 +27,9 @@ import {filterOutFalsyProperties} from '../utils/filter-object'; | |||
|
|||
const buildContextAriaAttributes: BuildAriaAttributesFn = ({ | |||
floating: {id, open}, | |||
ariaHasPopup, |
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 don't think we need to pass this down and then back up again. The purpose of BuildAriaAttributesFn
is to expose data from the BaseFloatingElement
that the Popover
can't access. But the Popover
has access to children.props
.
Can we simply move buildContextAriaAttributes
inside the component and change it to:
const buildContextAriaAttributes: BuildAriaAttributesFn = ({
floating: {id, open}
}) => ({
'aria-haspopup': children.props['aria-haspopup'] || 'dialog',
'aria-controls': open ? id : undefined,
});
I think this would achieve the same result without any changes to the base component.
What do you think?
* feat(PPDSC-2403): added role in props * feat(PPDSC-2403): removed unused code * feat(PPDSC-2403): disable the default aria-haspopup * feat(PPDSC-2403): linting fix * feat(PPDSC-2403): unit test case error fix * feat(PPDSC-2403): code patch fix * feat(PPDSC-2403): test case * feat(PPDSC-2403): simplified the condition Co-authored-by: Ravindren <jravindren@NTS251819MC.local>
PPDSC-2403
role
andaria-haspopup
on the popover component.Example:
role
andaria-haspopup
is to'dialog'
I have done:
I have tested manually:
Before:
After:
Who should review this PR:
How to test: