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

[popover2] feat: Popover2 popupkind #5300

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

dlech
Copy link
Contributor

@dlech dlech commented May 13, 2022

Fixes #0000

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

This adds a new popupKind property to the Popover2 component for controlling the aria-haspopup attribute of the target element.

The current implementation hard-codes aria-haspopup to "true" which means that the popup is a menu. However, this is not true in all cases. Furthermore, the aria-haspopup attribute should not be set for tooltips since they are not interactive elements. So if the interaction kind is a hover interaction, this new property is ignored.

Reference: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-haspopup

Reviewers should focus on:

Screenshot

Before:
image

After:
image

@dlech dlech force-pushed the popover2-popupkind branch 4 times, most recently from 8dc1942 to ff6de09 Compare May 13, 2022 19:55
@@ -50,14 +50,28 @@ export const Popover2InteractionKind = {
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type Popover2InteractionKind = typeof Popover2InteractionKind[keyof typeof Popover2InteractionKind];

/** Specifies the popup kind for aria-haspopup. */
export enum Popover2PopupKind {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can generalize this enum name and just call it PopupKind, and move it to a new file popupKind.ts in this package. Also please include a link to the docs in the JSDoc for this symbol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

packages/popover2/src/popover2.tsx Show resolved Hide resolved
@@ -327,7 +352,7 @@ export class Popover2<T> extends AbstractPureComponent2<Popover2Props<T>, IPopov
// Ensure target is focusable if relevant prop enabled
const targetTabIndex = openOnTargetFocus && isHoverInteractionKind ? 0 : undefined;
const targetProps = {
"aria-haspopup": "true",
"aria-haspopup": this.props.popupKind ?? (isHoverInteractionKind ? undefined : "true"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be only undefined if this.props.interactionKind === Popover2InteractionKind.HOVER_TARGET_ONLY.

in the case of Popover2InteractionKind.HOVER popovers, you can still interact with the content, and we have instances of that in our applications. so haspopup should be set to something.

when you make this change, please make sure to update the new prop JSDoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

});

it("renders without aria-haspopup attr for hover interaction", () => {
wrapper = renderPopover({ isOpen: true, interactionKind: Popover2InteractionKind.HOVER });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test will have to be updated if you make my change suggested above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

dlech added 4 commits June 2, 2022 17:18
This adds a new `popupKind` property to the `Popover2` component for
controlling the `aria-haspopup` attribute of the target element.

The current implementation hard-codes `aria-haspopup` to "true" which
means that the popup is a menu. However, this is not true in all cases.
Furthermore, the `aria-haspopup` attribute should not be set for
tooltips since they are not interactive elements. So if the interaction
kind is a hover interaction, this new property is ignored.

Reference: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-haspopup
@adidahiya
Copy link
Contributor

thanks @dlech!

@adidahiya adidahiya changed the title Popover2 popupkind [popover2] feat: Popover2 popupkind Jun 3, 2022
@adidahiya adidahiya merged commit 6ca55d9 into palantir:develop Jun 3, 2022
@dlech dlech deleted the popover2-popupkind branch June 3, 2022 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants