Skip to content

Commit 4db2dba

Browse files
committed
chore: unique it
1 parent 98cfa02 commit 4db2dba

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

docs/examples/two-buttons.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const MovingPopupDemo = () => {
5656
background: 'white',
5757
boxSizing: 'border-box',
5858
}}
59+
unique
5960
>
6061
<button type="button">左侧按钮</button>
6162
</Trigger>
@@ -76,6 +77,7 @@ const MovingPopupDemo = () => {
7677
background: 'white',
7778
boxSizing: 'border-box',
7879
}}
80+
unique
7981
>
8082
<button type="button">Right Button</button>
8183
</Trigger>

src/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ export interface TriggerProps {
111111
*/
112112
fresh?: boolean;
113113

114+
/**
115+
* Config with UniqueProvider to shared the floating popup.
116+
*/
117+
unique?: boolean;
118+
114119
// ==================== Arrow ====================
115120
arrow?: boolean | ArrowTypeOuter;
116121

@@ -173,6 +178,7 @@ export function generateTrigger(
173178
stretch,
174179
getPopupClassNameFromAlign,
175180
fresh,
181+
unique,
176182

177183
alignPoint,
178184

@@ -323,7 +329,7 @@ export function generateTrigger(
323329
// Handle controlled state changes for UniqueProvider
324330
// Only sync to UniqueProvider when it's controlled mode
325331
useLayoutEffect(() => {
326-
if (uniqueContext && targetEle && !openUncontrolled) {
332+
if (uniqueContext && unique && targetEle && !openUncontrolled) {
327333
if (mergedOpen) {
328334
Promise.resolve().then(() => {
329335
uniqueContext.show(getUniqueOptions(0));
@@ -370,7 +376,7 @@ export function generateTrigger(
370376
}
371377

372378
// If UniqueContext exists and not controlled, pass delay to Provider instead of handling it internally
373-
if (uniqueContext && openUncontrolled) {
379+
if (uniqueContext && unique && openUncontrolled) {
374380
if (nextOpen) {
375381
uniqueContext.show(getUniqueOptions(delay));
376382
} else {
@@ -769,7 +775,7 @@ export function generateTrigger(
769775
>
770776
{triggerNode}
771777
</ResizeObserver>
772-
{rendedRef.current && !uniqueContext && (
778+
{rendedRef.current && (!uniqueContext || !unique) && (
773779
<TriggerContext.Provider value={context}>
774780
<Popup
775781
portal={PortalComponent}

0 commit comments

Comments
 (0)