Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ storybook-static
# Jetbrains IDEs
.idea

# VS Code IDE
.vscode

.npmrc

.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sofarsounds/maestro",
"version": "7.4.19",
"version": "7.4.20",
"description": "The official sofar sounds react uikit library",
"main": "dist/index.js",
"scripts": {
Expand Down
15 changes: 13 additions & 2 deletions src/hooks/useSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface Props<T> {
filterBy?: (option: T, query: string) => boolean;
defaultOptions: T[];
value?: T | null;
controlledInputValue?: string;
setControlledInputValue?: React.Dispatch<React.SetStateAction<string>>;
}

interface ReturnProps<T> {
Expand All @@ -33,12 +35,21 @@ const useSelect = <T extends {}>({
searchable,
filterBy,
value,
onChange
onChange,
controlledInputValue,
setControlledInputValue
}: Props<T>): ReturnProps<T> => {
const ref = useRef<HTMLInputElement>();
const [isOpen, setIsOpen] = useState<boolean>(false);
const [selected, setSelected] = useState(defaultValue);
const [inputValue, setInputValue] = useState('');
const [uncontrolledInputValue, setUncontrolledInputValue] = useState('');

const inputValue = controlledInputValue
? controlledInputValue
: uncontrolledInputValue;
const setInputValue = setControlledInputValue
? setControlledInputValue
: setUncontrolledInputValue;

const onOptionClick = useCallback(
(option: T | null) => {
Expand Down
2 changes: 1 addition & 1 deletion src/molecules/Select/Options/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Options = <T extends {}>({
);
}
case SelectState.ready: {
if (options.length === 0) {
if (options.length === 0 && userIsSearching) {
return (
<MenuItem disabled data-qaid={`${qaId}-empty-msg`}>
No options...
Expand Down
8 changes: 7 additions & 1 deletion src/molecules/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface SelectProps<T> extends OptionsListProps<T> {
hasError?: boolean;
invertColor?: boolean;
renderLeftIcon?: React.ReactNode;
inputValue?: string;
setInputValue?: React.Dispatch<React.SetStateAction<string>>;

// typeahead props
searchable?: boolean;
Expand Down Expand Up @@ -63,6 +65,8 @@ const Select = <T extends {}>({
initialWidth,
state = SelectState.ready,
disableScrollWhenOpen = false,
inputValue,
setInputValue,
'data-qaid': qaId
}: SelectProps<T>) => {
const {
Expand All @@ -81,7 +85,9 @@ const Select = <T extends {}>({
filterBy,
defaultOptions,
// @ts-ignore
onChange
onChange,
controlledInputValue: inputValue,
setControlledInputValue: setInputValue
});

return (
Expand Down