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

style: PopupKind default to "menu" #6647

Merged
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
13 changes: 6 additions & 7 deletions packages/core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ export interface PopoverProps<TProps extends DefaultPopoverTargetHTMLProps = Def
interactionKind?: PopoverInteractionKind;

/**
* The kind of popup displayed by the popover. This property is ignored if
* `interactionKind` is {@link PopoverInteractionKind.HOVER_TARGET_ONLY}.
* This controls the `aria-haspopup` attribute of the target element. The
* default is "menu" (technically, `aria-haspopup` will be set to "true",
* which is the same as "menu", for backwards compatibility).
* The kind of popup displayed by the popover. Gets directly applied to the
* `aria-haspopup` attribute of the target element. This property is
* ignored if `interactionKind` is {@link PopoverInteractionKind.HOVER_TARGET_ONLY}.
*
* @default "menu" or undefined
*/
Expand Down Expand Up @@ -388,8 +386,9 @@ export class Popover<
const childTargetProps = {
"aria-expanded": isOpen,
"aria-haspopup":
this.props.popupKind ??
(this.props.interactionKind === PopoverInteractionKind.HOVER_TARGET_ONLY ? undefined : true),
this.props.interactionKind === PopoverInteractionKind.HOVER_TARGET_ONLY
? undefined
: this.props.popupKind ?? "menu",
} satisfies React.HTMLProps<HTMLElement>;

const targetModifierClasses = {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/popover/popoverTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe("<Popover>", () => {

it("renders with aria-haspopup attr", () => {
wrapper = renderPopover({ isOpen: true });
assert.isTrue(wrapper.find("[aria-haspopup=true]").exists());
assert.isTrue(wrapper.find("[aria-haspopup='menu']").exists());
});

it("sets aria-haspopup attr base on popupKind", () => {
Expand Down