-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: migrate autocomplete component #21323
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
base: main
Are you sure you want to change the base?
Conversation
| getOptionLabel={(option) => option.email} | ||
| onOpen={() => { | ||
| setOpen(true); | ||
| setFilter(value?.email ?? ""); |
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.
Im not sure why setFilter was previously set to value?.email, this made it very difficult to choose a different value for the owner on the Create workspace page
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.
For example, try out the existing owner autocomplete dropdown vs the one in this PR, I cant think of a reason why the existing one is difficult to use.
418bd76 to
d99aee4
Compare
| * Container element to portal the dropdown into. Use this when rendering | ||
| * inside a Dialog to avoid scroll lock issues. | ||
| */ | ||
| popoverContainer?: HTMLElement | 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.
passing an element as a prop feels like a smell to me. I notice tho that the one place we're using this is to pull an element out of the ref.
can we just pass the ref instead?
| if (isOpen) { | ||
| setFilter(""); | ||
| } else { | ||
| setFilter(undefined); | ||
| } |
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.
you could also just do setFilter(isOpen ? "" : undefined)
| <Avatar | ||
| src={option.created_by.avatar_url} | ||
| fallback={option.name} | ||
| <Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}> |
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.
I really am not a fan of the readability of using && short circuiting this way, and would rather just make this an if
| getOptionValue={(option) => option.name} | ||
| getOptionLabel={(option) => option.name} | ||
| renderOption={(option) => ( | ||
| <span className="flex-1">{`${option.flag} ${option.name}`}</span> |
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.
| <span className="flex-1">{`${option.flag} ${option.name}`}</span> | |
| <span className="flex-1">{option.flag} {option.name}</span> |
| <span className="flex-1">{`${option.flag} ${option.name}`}</span> | ||
| )} | ||
| label={Language.countryLabel} | ||
| placeholder={"Select a country"} |
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 remove the {}
| export const ChangeWorkspaceVersionDialog: FC< | ||
| ChangeWorkspaceVersionDialogProps | ||
| > = ({ workspace, onClose, onConfirm, ...dialogProps }) => { | ||
| > = ({ open, workspace, onClose, onConfirm }) => { |
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.
Any reason we wouldn't want the rest of these ...dialogProps here?
Also, adds built-in required and error text