@rovula/ui 0.0.65 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -82,7 +82,7 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
82
82
|
error = false,
|
|
83
83
|
filterMode = false,
|
|
84
84
|
required = true,
|
|
85
|
-
modal =
|
|
85
|
+
modal = false,
|
|
86
86
|
onChangeText,
|
|
87
87
|
onSelect,
|
|
88
88
|
renderOptions: customRenderOptions,
|
|
@@ -158,6 +158,8 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
158
158
|
);
|
|
159
159
|
}, [options, filterMode, textValue]);
|
|
160
160
|
|
|
161
|
+
const usePortal = isInsideDialog ? false : modal;
|
|
162
|
+
|
|
161
163
|
const updateDropdownPosition = useCallback(() => {
|
|
162
164
|
if (inputRef.current && dropdownRef.current) {
|
|
163
165
|
const rect = inputRef.current.getBoundingClientRect();
|
|
@@ -169,8 +171,6 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
169
171
|
spaceBelow < dropdownHeight && spaceAbove > spaceBelow;
|
|
170
172
|
setIsAbove(shouldOpenAbove);
|
|
171
173
|
|
|
172
|
-
const usePortal = isInsideDialog ? false : modal;
|
|
173
|
-
|
|
174
174
|
if (usePortal) {
|
|
175
175
|
setDropdownStyles({
|
|
176
176
|
position: "absolute",
|
|
@@ -179,7 +179,7 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
179
179
|
: `${rect.bottom}px`,
|
|
180
180
|
left: `${rect.left}px`,
|
|
181
181
|
width: `${rect.width}px`,
|
|
182
|
-
zIndex: 9999,
|
|
182
|
+
zIndex: 9999,
|
|
183
183
|
});
|
|
184
184
|
} else {
|
|
185
185
|
setDropdownStyles({
|
|
@@ -187,22 +187,20 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
187
187
|
top: shouldOpenAbove ? `-${dropdownHeight}px` : "100%",
|
|
188
188
|
left: "0",
|
|
189
189
|
width: "100%",
|
|
190
|
-
zIndex:
|
|
190
|
+
zIndex: 9999,
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
}, [modal, isInsideDialog]);
|
|
194
|
+
}, [modal, isInsideDialog, usePortal]);
|
|
195
195
|
|
|
196
196
|
useEffect(() => {
|
|
197
197
|
if (isFocused) {
|
|
198
198
|
updateDropdownPosition();
|
|
199
199
|
window.addEventListener("resize", updateDropdownPosition);
|
|
200
|
-
window.addEventListener("scroll", updateDropdownPosition, true);
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
return () => {
|
|
204
203
|
window.removeEventListener("resize", updateDropdownPosition);
|
|
205
|
-
window.removeEventListener("scroll", updateDropdownPosition, true);
|
|
206
204
|
};
|
|
207
205
|
}, [isFocused, updateDropdownPosition]);
|
|
208
206
|
|
|
@@ -221,7 +219,7 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
221
219
|
<ul
|
|
222
220
|
className={cn(
|
|
223
221
|
"absolute mt-1 w-full bg-base-popup border border-base-popup text-base-popup-foreground rounded-md shadow-md z-[9999] max-h-60 overflow-y-auto",
|
|
224
|
-
isAbove ? "bottom-full mb-1" : "top-full mt-1",
|
|
222
|
+
!usePortal && (isAbove ? "bottom-full mb-1" : "top-full mt-1"),
|
|
225
223
|
optionContainerClassName
|
|
226
224
|
)}
|
|
227
225
|
style={dropdownStyles}
|
|
@@ -337,7 +335,7 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
337
335
|
);
|
|
338
336
|
|
|
339
337
|
return (
|
|
340
|
-
<div className={`relative
|
|
338
|
+
<div className={`relative ${fullwidth ? "w-full" : ""}`}>
|
|
341
339
|
<TextInput
|
|
342
340
|
hasClearIcon={false}
|
|
343
341
|
endIcon={
|
|
@@ -372,7 +370,7 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
372
370
|
onKeyDown={handleOnKeyDown}
|
|
373
371
|
/>
|
|
374
372
|
{isFocused &&
|
|
375
|
-
(
|
|
373
|
+
(usePortal ? (
|
|
376
374
|
<Portal.Root container={document.body}>
|
|
377
375
|
{renderOptions()}
|
|
378
376
|
</Portal.Root>
|