-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(677) enable users to enter text into drop down boxes #737
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just a couple 💅 , thanks a lot @tplevko
if (value) { | ||
if (value === 'create') { | ||
if (!allOptions.some((item) => item.value === filterValue)) { | ||
allOptions = [...allOptions, { value: filterValue, children: filterValue }]; | ||
} | ||
setSelected(filterValue); | ||
setOnCreation(!onCreation); | ||
props.onChange(filterValue); | ||
setFilterValue(''); | ||
} else { | ||
setInputValue(value as string); | ||
setFilterValue(''); | ||
setSelected(value as string); | ||
props.onChange(value as string); | ||
} | ||
} | ||
setIsOpen(false); | ||
setFocusedItemIndex(null); | ||
setActiveItem(null); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious-question]: Wouldn't this nested if
be simplified as:
if (value === 'create') {
if (!allOptions.some((item) => item.value === filterValue)) {
allOptions = [...allOptions, { value: filterValue, children: filterValue }];
}
setSelected(filterValue);
setOnCreation(!onCreation);
props.onChange(filterValue);
setFilterValue('');
} else {
setInputValue(value as string);
setFilterValue('');
setSelected(value as string);
props.onChange(value as string);
}
}
setIsOpen(false);
setFocusedItemIndex(null);
setActiveItem(null);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you're right, the first check was redundant. Updated.
|
||
TypeaheadField.defaultProps = {}; | ||
|
||
export default connectField(TypeaheadField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could export this component with a name?
As an example, like we do for the DisabledField
export const DisabledField = connectField((props: ConnectedFieldProps<CustomStepsFieldProps>) => {
return (
<Card>
<CardTitle>{props.label}</CardTitle>
<CardBody>
<ExpandableDetails details={props}>
<p>Configuring this field is not yet supported</p>
</ExpandableDetails>
</CardBody>
</Card>
);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, updated to export with a name.
79f5604
to
0c9a98c
Compare
fix: #677
fix: #512
With the typeahead with create
vokoscreenNG-2024-01-26_13-34-14.mp4