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

Adds more info into payments popover and mirrors state to URL query #40

Merged
merged 8 commits into from
Jun 19, 2021
Prev Previous commit
Fixed issues with mouse select in search handle field.
  • Loading branch information
MadOPcode committed Jun 19, 2021
commit b2f5333dd4ca75cfee84b85499d7b18a906d5da0
24 changes: 21 additions & 3 deletions src/components/SearchHandleField/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ function MenuList(props) {
focusedOption = props.selectProps.isMenuFocused
? focusedOption
: props.getValue()[0];
const setIsMenuFocused = props.selectProps.setIsMenuFocused;

return <components.MenuList {...props} focusedOption={focusedOption} />;
const onMouseEnter = useCallback(() => {
setIsMenuFocused(true);
}, [setIsMenuFocused]);

return (
<div className={styles.menuList} onMouseEnter={onMouseEnter}>
<components.MenuList {...props} focusedOption={focusedOption} />
</div>
);
}
MenuList.propTypes = {
focusedOption: PT.object,
getValue: PT.func,
selectProps: PT.shape({
isMenuFocused: PT.oneOfType([PT.bool, PT.number]),
setIsMenuFocused: PT.func,
}),
};

Expand Down Expand Up @@ -133,7 +143,7 @@ const SearchHandleField = ({
if (key === "Enter" || key === "Escape") {
setIsMenuFocused(false);
setIsMenuOpen(false);
if (!inputValue) {
if (!isMenuFocused) {
onChange(inputValue);
}
} else if (key === "ArrowDown") {
Expand Down Expand Up @@ -161,7 +171,14 @@ const SearchHandleField = ({
}, [value]);

return (
<div className={cn(styles.container, styles[size], className)}>
<div
className={cn(
styles.container,
styles[size],
{ [styles.isMenuFocused]: isMenuFocused },
className
)}
>
<span className={styles.icon} />
<Select
className={styles.select}
Expand All @@ -173,6 +190,7 @@ const SearchHandleField = ({
isSearchable={true}
isLoading={isLoading}
isMenuFocused={isMenuFocused}
setIsMenuFocused={setIsMenuFocused}
menuIsOpen={isMenuOpen}
value={null}
inputValue={inputValue}
Expand Down
12 changes: 11 additions & 1 deletion src/components/SearchHandleField/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ input.input {
}
}

.menuList {
display: block;
}

.select {
z-index: 1;
position: relative;
Expand Down Expand Up @@ -157,7 +161,6 @@ input.input {
}
}

:global(.custom__option--is-focused),
:global(.custom__option--is-selected) {
background-color: $primary-text-color !important;
color: #fff;
Expand All @@ -167,3 +170,10 @@ input.input {
display: none;
}
}

.isMenuFocused {
:global(.custom__option--is-focused) {
background-color: $primary-text-color !important;
color: #fff;
}
}