Skip to content

Commit 39e1a6a

Browse files
committed
fix: hide drop-down when options is empty when clicked on select input
1 parent dc035ac commit 39e1a6a

File tree

5 files changed

+12
-28
lines changed

5 files changed

+12
-28
lines changed

src/App/PageError/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
22
import { useRouteError } from 'react-router-dom';
33

44
import useBooleanState from '#hooks/useBooleanState';
5-
import Button from '#components/Button';
5+
import Button, { useButtonFeatures } from '#components/Button';
66

77
import styles from './styles.module.css';
88

@@ -24,6 +24,9 @@ function PageError() {
2424
toggle: toggleFullErrorVisibility,
2525
},
2626
] = useBooleanState(false);
27+
const {
28+
className: containerClassName,
29+
} = useButtonFeatures({});
2730

2831
return (
2932
<div className={styles.pageError}>
@@ -62,8 +65,9 @@ function PageError() {
6265
)}
6366
</div>
6467
<div className={styles.footer}>
68+
{/* NOTE: using the anchor element as it will refresh the page */}
6569
<a
66-
className={styles.homeLink}
70+
className={containerClassName}
6771
href="/"
6872
>
6973
{/* FIXME: use translations */}

src/App/PageError/styles.module.css

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,6 @@
4343
display: flex;
4444
align-items: center;
4545
justify-content: flex-end;
46-
47-
.home-link {
48-
display: inline-flex;
49-
align-items: center;
50-
transition: var(--go-ui-duration-transition-medium) background-color ease-in-out;
51-
border-radius: var(--go-ui-border-radius-full);
52-
background-color: var(--go-ui-color-primary-red);
53-
padding: var(--go-ui-spacing-4xs) var(--go-ui-spacing-sm);
54-
text-decoration: none;
55-
color: var(--go-ui-color-white);
56-
57-
&:hover {
58-
background-color: var(--go-ui-color-red-hover);
59-
text-decoration: underline;
60-
}
61-
}
6246
}
6347
}
6448
}

src/components/SearchMultiSelectInput/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,7 @@ function SearchMultiSelectInput<
299299
onClearButtonClick={handleClear}
300300
searchText={searchInputValue}
301301
onSearchTextChange={handleSearchValueChange}
302-
dropdownShown={showDropdown && (
303-
(isTruthyString(searchInputValue) && searchInputValue.length > 0)
304-
|| realOptions.length > 0
305-
)}
302+
dropdownShown={showDropdown}
306303
onDropdownShownChange={handleChangeDropdown}
307304
focused={focused}
308305
onFocusedChange={setFocused}

src/components/SearchSelectInput/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,7 @@ function SearchSelectInput<
310310
onClearButtonClick={handleClear}
311311
searchText={searchInputValue}
312312
onSearchTextChange={handleSearchValueChange}
313-
dropdownShown={showDropdown && (
314-
(isTruthyString(searchInputValue) && searchInputValue.length > 0)
315-
|| realOptions.length > 0
316-
)}
313+
dropdownShown={showDropdown}
317314
onDropdownShownChange={handleChangeDropdown}
318315
focused={focused}
319316
onFocusedChange={setFocused}

src/components/SelectInputContainer/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ function SelectInputContainer<
183183
if (readOnly) {
184184
return;
185185
}
186-
handleShowDropdown();
186+
if (options.length > 0) {
187+
handleShowDropdown();
188+
}
187189
},
188-
[readOnly, handleShowDropdown],
190+
[readOnly, handleShowDropdown, options],
189191
);
190192

191193
const handlePopupBlur = useCallback(

0 commit comments

Comments
 (0)