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

fix: use trigger prop for aria-haspopup #24794

Merged
merged 5 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Remove `rotate(360deg)` from `PopupContent` content styles @yuanboxue-amber ([#24432](https://github.com/microsoft/fluentui/pull/24432))
- Fix `FocusZone` to reset tabindex when focus is outside the zone with prop `shouldResetActiveElementWhenTabFromZone` @yuanboxue-amber ([#24463](https://github.com/microsoft/fluentui/pull/24463))
- Change `useLayoutEffect` in `Dropdown` to `useIsomorphicLayoutEffect` @marwan38 ([#24559](https://github.com/microsoft/fluentui/pull/24559))
- Fix `Popup` trigger attribute being override @chpalac ([#24794](https://github.com/microsoft/fluentui/pull/24794))
- Fix styling mutation when merging themes in `Dropdown` @petrjaros ([#24787](https://github.com/microsoft/fluentui/pull/24787))

### Performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const popupBehavior: Accessibility<PopupBehaviorProps> = props => {
: undefined;

if (tabbableTriggerProps) {
tabbableTriggerProps['aria-haspopup'] = 'dialog';
tabbableTriggerProps['aria-haspopup'] = props.trigger?.props.hasOwnProperty('aria-haspopup')
chpalac marked this conversation as resolved.
Show resolved Hide resolved
? props.trigger?.props['aria-haspopup']
: 'dialog';

if (process.env.NODE_ENV !== 'production') {
// Override the default trigger's accessibility schema class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ describe('PopupBehavior.ts', () => {
expect(expectedResult.attributes.trigger.tabIndex).toEqual(-1);
});

test('Do not override trigger aria-haspopup attribute', () => {
const expectedResult = popupBehavior({
trigger: <button aria-haspopup={null} />,
tabbableTrigger: true,
});
expect(expectedResult.attributes.trigger['aria-haspopup']).toBeNull();
});

// TODO: Fix me
// test('does not add tabIndex if element is already tabbable', () => {
// const expectedResult = popupBehavior({ trigger: <Button />, tabbableTrigger: true })
Expand Down