Skip to content

Commit 5d62cb0

Browse files
authored
Merge pull request #475 from mashmatrix/support-slds-2-popover
Update `Popover` for SLDS2
2 parents 982b4c7 + 7a9263f commit 5d62cb0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/scripts/Popover.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, {
44
FC,
55
ReactNode,
66
forwardRef,
7+
useId,
78
useEffect,
89
} from 'react';
910
import classnames from 'classnames';
@@ -70,13 +71,13 @@ export type PopoverProps = {
7071
bodyStyle?: CSSProperties;
7172
offsetX?: number;
7273
offsetY?: number;
73-
} & HTMLAttributes<HTMLDivElement>;
74+
} & HTMLAttributes<HTMLElement>;
7475

7576
/**
7677
*
7778
*/
7879
export const PopoverInner = forwardRef<
79-
HTMLDivElement,
80+
HTMLElement,
8081
PopoverProps & AutoAlignInjectedProps
8182
>((props, ref) => {
8283
const {
@@ -117,16 +118,20 @@ export const PopoverInner = forwardRef<
117118
: undefined
118119
: undefined,
119120
};
121+
const bodyId = useId();
120122
return (
121-
<div
123+
<section
122124
ref={ref}
123125
className={popoverClassNames}
124126
role={tooltip ? 'tooltip' : 'dialog'}
125127
style={rootStyle}
128+
aria-describedby={bodyId}
126129
{...rprops}
127130
>
128-
<PopoverBody style={bodyStyle}>{children}</PopoverBody>
129-
</div>
131+
<PopoverBody id={bodyId} style={bodyStyle}>
132+
{children}
133+
</PopoverBody>
134+
</section>
130135
);
131136
});
132137

stories/Popover.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const paddingDecorator: DecoratorFn = (story) => (
2020
padding: '100px 350px',
2121
}}
2222
>
23-
<div className='slds-dropdown-trigger'>
23+
<div className='slds-dropdown-trigger slds-dropdown-trigger_click'>
2424
<Button type='icon' icon='question' />
2525
{story()}
2626
</div>

0 commit comments

Comments
 (0)