fix: Select dropdown scrolling and Style node border
Browse files- Add dropdownRef to portaled dropdown so click-outside handler
ignores scrollbar / item clicks instead of closing the menu
- Remove extra bg/border classes from Style node Select to match
other nodes and let the component own its theme-aware styling
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- app/nodes.tsx +3 -3
- components/ui/select.tsx +6 -3
app/nodes.tsx
CHANGED
|
@@ -1698,13 +1698,13 @@ export function StyleNodeView({ node, onDelete, onUpdate, onStartConnection, onE
|
|
| 1698 |
<div className="text-xs text-muted-foreground">Art Style</div>
|
| 1699 |
<div className="text-xs text-muted-foreground/50 mb-2">Select an artistic style to apply to your image</div>
|
| 1700 |
<Select
|
| 1701 |
-
className="w-full
|
| 1702 |
value={node.stylePreset || ""}
|
| 1703 |
onChange={(e) => onUpdate(node.id, { stylePreset: (e.target as HTMLSelectElement).value })}
|
| 1704 |
>
|
| 1705 |
-
<option value=""
|
| 1706 |
{styleOptions.map(opt => (
|
| 1707 |
-
<option key={opt.value} value={opt.value}
|
| 1708 |
{opt.label}
|
| 1709 |
</option>
|
| 1710 |
))}
|
|
|
|
| 1698 |
<div className="text-xs text-muted-foreground">Art Style</div>
|
| 1699 |
<div className="text-xs text-muted-foreground/50 mb-2">Select an artistic style to apply to your image</div>
|
| 1700 |
<Select
|
| 1701 |
+
className="w-full"
|
| 1702 |
value={node.stylePreset || ""}
|
| 1703 |
onChange={(e) => onUpdate(node.id, { stylePreset: (e.target as HTMLSelectElement).value })}
|
| 1704 |
>
|
| 1705 |
+
<option value="">Select a style...</option>
|
| 1706 |
{styleOptions.map(opt => (
|
| 1707 |
+
<option key={opt.value} value={opt.value}>
|
| 1708 |
{opt.label}
|
| 1709 |
</option>
|
| 1710 |
))}
|
components/ui/select.tsx
CHANGED
|
@@ -10,6 +10,7 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
| 10 |
const [dropdownStyle, setDropdownStyle] = React.useState<React.CSSProperties>({});
|
| 11 |
const containerRef = React.useRef<HTMLDivElement>(null);
|
| 12 |
const triggerRef = React.useRef<HTMLButtonElement>(null);
|
|
|
|
| 13 |
|
| 14 |
const options = React.useMemo(() => {
|
| 15 |
const opts: { value: string; label: string; disabled?: boolean }[] = [];
|
|
@@ -57,9 +58,10 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
| 57 |
React.useEffect(() => {
|
| 58 |
if (!open) return;
|
| 59 |
const handler = (e: MouseEvent) => {
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
setOpen(false);
|
| 64 |
}
|
| 65 |
};
|
|
@@ -78,6 +80,7 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
| 78 |
|
| 79 |
const dropdown = open ? (
|
| 80 |
<div
|
|
|
|
| 81 |
style={dropdownStyle}
|
| 82 |
className="nb-select-list rounded-xl border overflow-hidden shadow-lg"
|
| 83 |
>
|
|
|
|
| 10 |
const [dropdownStyle, setDropdownStyle] = React.useState<React.CSSProperties>({});
|
| 11 |
const containerRef = React.useRef<HTMLDivElement>(null);
|
| 12 |
const triggerRef = React.useRef<HTMLButtonElement>(null);
|
| 13 |
+
const dropdownRef = React.useRef<HTMLDivElement>(null);
|
| 14 |
|
| 15 |
const options = React.useMemo(() => {
|
| 16 |
const opts: { value: string; label: string; disabled?: boolean }[] = [];
|
|
|
|
| 58 |
React.useEffect(() => {
|
| 59 |
if (!open) return;
|
| 60 |
const handler = (e: MouseEvent) => {
|
| 61 |
+
const target = e.target as Node;
|
| 62 |
+
const insideContainer = containerRef.current?.contains(target);
|
| 63 |
+
const insideDropdown = dropdownRef.current?.contains(target);
|
| 64 |
+
if (!insideContainer && !insideDropdown) {
|
| 65 |
setOpen(false);
|
| 66 |
}
|
| 67 |
};
|
|
|
|
| 80 |
|
| 81 |
const dropdown = open ? (
|
| 82 |
<div
|
| 83 |
+
ref={dropdownRef}
|
| 84 |
style={dropdownStyle}
|
| 85 |
className="nb-select-list rounded-xl border overflow-hidden shadow-lg"
|
| 86 |
>
|