Skip to content

Commit 7c75e13

Browse files
committed
fix(popover): not opening
1 parent 9f3166d commit 7c75e13

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

core/components/atoms/popperWrapper/PopperWrapper.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ interface PopoverTriggerProps {
181181
}
182182

183183
export const PopoverTrigger = React.forwardRef<HTMLElement, React.HTMLProps<HTMLElement> & PopoverTriggerProps>(
184-
function PopoverTrigger({ children, asChild = false, ...props }, propRef) {
184+
function PopoverTrigger({ children, asChild = false, triggerClass, ...props }, propRef) {
185185
const context = usePopoverContext();
186186
const childrenRef = (children as any).ref;
187187
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
@@ -204,7 +204,7 @@ export const PopoverTrigger = React.forwardRef<HTMLElement, React.HTMLProps<HTML
204204
};
205205

206206
if (asChild) {
207-
return <div className={props.triggerClass}>{getClonedElement()}</div>;
207+
return <div className={triggerClass}>{getClonedElement()}</div>;
208208
}
209209

210210
return (
@@ -232,33 +232,36 @@ export const PopoverContent = React.forwardRef<HTMLDivElement, React.HTMLProps<H
232232

233233
const { isMounted, styles, portalRoot, appendToBody } = context;
234234

235-
const boundaryElement = appendToBody && document ? document.body : portalRoot;
235+
const boundaryElement = appendToBody !== false && document ? document.body : portalRoot;
236236

237237
const isValidPosition = context.x !== 0 && context.y !== 0;
238238
const showVisibility =
239239
context.middlewareData.hide?.referenceHidden || context.middlewareData.hide?.escaped || !isValidPosition;
240240

241-
return (
242-
<FloatingPortal root={boundaryElement}>
243-
{isMounted && (
244-
// <FloatingFocusManager context={floatingContext}
245-
// // modal={context.modal}
246-
// initialFocus={-1}>
247-
<div
248-
ref={ref}
249-
style={{
250-
...context.floatingStyles,
251-
...style,
252-
visibility: showVisibility ? 'hidden' : 'visible',
253-
}}
254-
{...context.getFloatingProps(props)}
255-
>
256-
<div style={styles}>{props.children}</div>
257-
</div>
258-
// </FloatingFocusManager>
259-
)}
260-
</FloatingPortal>
241+
const content = isMounted && (
242+
// <FloatingFocusManager context={floatingContext}
243+
// // modal={context.modal}
244+
// initialFocus={-1}>
245+
<div
246+
ref={ref}
247+
style={{
248+
...context.floatingStyles,
249+
...style,
250+
visibility: showVisibility ? 'hidden' : 'visible',
251+
}}
252+
{...context.getFloatingProps(props)}
253+
>
254+
<div style={styles}>{props.children}</div>
255+
</div>
256+
// </FloatingFocusManager>
261257
);
258+
259+
// If appendToBody is explicitly false and no portalRoot is provided, don't use portal
260+
if (appendToBody === false && !portalRoot) {
261+
return content;
262+
}
263+
264+
return <FloatingPortal root={boundaryElement}>{content}</FloatingPortal>;
262265
});
263266

264267
export default PopperWrapper;

core/components/organisms/select/utils.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export const mapInitialValue = (multiSelect: boolean, selectedValue: OptionType
1010
};
1111

1212
export const elementExist = (targetObject: OptionType, mainList: OptionType | OptionType[] | undefined) => {
13+
if (!targetObject || !targetObject.label) {
14+
return -1;
15+
}
1316
if (!Array.isArray(mainList)) {
1417
return targetObject.label === mainList?.label ? 0 : -1;
1518
}

0 commit comments

Comments
 (0)