Skip to content

Commit 05c0d01

Browse files
committed
Fix gap between options panel and search input in single dropdown
1 parent e367533 commit 05c0d01

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/library/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@luciodale/react-searchable-dropdown",
3-
"version": "1.0.4",
3+
"version": "1.0.41",
44
"author": "Lucio D'Alessandro",
55
"repository": {
66
"type": "git",

packages/library/src/SearchableDropdown.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FloatingPortal } from "@floating-ui/react";
2-
import { useCallback } from "react";
2+
import { useCallback, useRef } from "react";
33
import { GroupedVirtuoso, Virtuoso } from "react-virtuoso";
44
import { DropdownIconDefault } from "./components/DropdownIconDefault";
55
import { DropdownOption } from "./components/DropdownOption";
@@ -96,8 +96,7 @@ export function SearchableDropdown<T extends TDropdownOption, G>({
9696
enhanceOptionsWithNewCreation,
9797
});
9898

99-
const searchQueryinputRef = core.refs
100-
.reference as React.MutableRefObject<HTMLInputElement | null>;
99+
const searchQueryinputRef = useRef<HTMLInputElement | null>(null);
101100

102101
const currentOptionIsSelectedCallback = useCallback(
103102
(option: TDropdownOption) => {
@@ -213,11 +212,12 @@ export function SearchableDropdown<T extends TDropdownOption, G>({
213212

214213
return (
215214
<div
215+
ref={core.refs.setReference}
216216
className={`${BASE_CLASS} ${classNameSearchableDropdownContainer} ${disabled ? "disabled" : ""}`}
217217
onKeyDown={handleKeyDown}
218218
>
219219
<input
220-
ref={core.refs.setReference}
220+
ref={searchQueryinputRef}
221221
type="text"
222222
role="combobox"
223223
aria-expanded={core.showDropdownOptions}

0 commit comments

Comments
 (0)