Skip to content
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

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

tplevko
Copy link
Contributor

@tplevko tplevko commented Jan 25, 2024

fix: #677
fix: #512

With the typeahead with create

vokoscreenNG-2024-01-26_13-34-14.mp4

@tplevko tplevko marked this pull request as ready for review January 29, 2024 11:39
Copy link
Member

@lordrip lordrip left a 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

Comment on lines 82 to 99
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);
};
Copy link
Member

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);
  };

Copy link
Contributor Author

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);
Copy link
Member

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?
image

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>
  );
});

Copy link
Contributor Author

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.

@tplevko tplevko force-pushed the issue_677 branch 2 times, most recently from 79f5604 to 0c9a98c Compare January 29, 2024 13:44
@lordrip lordrip merged commit 861ce12 into KaotoIO:main Jan 29, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enable users to enter text into drop down boxes make enum values accept strings additionally
2 participants