Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit b2f5333

Browse files
committed
Fixed issues with mouse select in search handle field.
1 parent 8759232 commit b2f5333

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/components/SearchHandleField/index.jsx

+21-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,24 @@ function MenuList(props) {
1616
focusedOption = props.selectProps.isMenuFocused
1717
? focusedOption
1818
: props.getValue()[0];
19+
const setIsMenuFocused = props.selectProps.setIsMenuFocused;
1920

20-
return <components.MenuList {...props} focusedOption={focusedOption} />;
21+
const onMouseEnter = useCallback(() => {
22+
setIsMenuFocused(true);
23+
}, [setIsMenuFocused]);
24+
25+
return (
26+
<div className={styles.menuList} onMouseEnter={onMouseEnter}>
27+
<components.MenuList {...props} focusedOption={focusedOption} />
28+
</div>
29+
);
2130
}
2231
MenuList.propTypes = {
2332
focusedOption: PT.object,
2433
getValue: PT.func,
2534
selectProps: PT.shape({
2635
isMenuFocused: PT.oneOfType([PT.bool, PT.number]),
36+
setIsMenuFocused: PT.func,
2737
}),
2838
};
2939

@@ -133,7 +143,7 @@ const SearchHandleField = ({
133143
if (key === "Enter" || key === "Escape") {
134144
setIsMenuFocused(false);
135145
setIsMenuOpen(false);
136-
if (!inputValue) {
146+
if (!isMenuFocused) {
137147
onChange(inputValue);
138148
}
139149
} else if (key === "ArrowDown") {
@@ -161,7 +171,14 @@ const SearchHandleField = ({
161171
}, [value]);
162172

163173
return (
164-
<div className={cn(styles.container, styles[size], className)}>
174+
<div
175+
className={cn(
176+
styles.container,
177+
styles[size],
178+
{ [styles.isMenuFocused]: isMenuFocused },
179+
className
180+
)}
181+
>
165182
<span className={styles.icon} />
166183
<Select
167184
className={styles.select}
@@ -173,6 +190,7 @@ const SearchHandleField = ({
173190
isSearchable={true}
174191
isLoading={isLoading}
175192
isMenuFocused={isMenuFocused}
193+
setIsMenuFocused={setIsMenuFocused}
176194
menuIsOpen={isMenuOpen}
177195
value={null}
178196
inputValue={inputValue}

src/components/SearchHandleField/styles.module.scss

+11-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ input.input {
4141
}
4242
}
4343

44+
.menuList {
45+
display: block;
46+
}
47+
4448
.select {
4549
z-index: 1;
4650
position: relative;
@@ -157,7 +161,6 @@ input.input {
157161
}
158162
}
159163

160-
:global(.custom__option--is-focused),
161164
:global(.custom__option--is-selected) {
162165
background-color: $primary-text-color !important;
163166
color: #fff;
@@ -167,3 +170,10 @@ input.input {
167170
display: none;
168171
}
169172
}
173+
174+
.isMenuFocused {
175+
:global(.custom__option--is-focused) {
176+
background-color: $primary-text-color !important;
177+
color: #fff;
178+
}
179+
}

0 commit comments

Comments
 (0)