-
Notifications
You must be signed in to change notification settings - Fork 364
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
refactor: [M3-6922] - Add Autocomplete Component #9497
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.
This is really nice and clean. Great work!
Added some comments to clean things up.
Also, have we discussed the use of the "Autocomplete" VS "Select" nomenclature. I don't think it is a crucial discussion but I'd be curious to know why gearing towards the MUI naming convention rather than keeping our existing one
value: string; | ||
} | ||
|
||
export interface AutocompleteProps { |
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 are overriding a lot of MUI Autocomplete
props which I think we should avoid to prevent breaking changes when updating MUI. Rather we should extend the MUI component's props and only declare our custom props. (same with other interfaces below)
They will be automatically picked up by storybook
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.
Consider this done!
sx, | ||
} = props; | ||
|
||
const [inputValue, setInputValue] = React.useState(''); |
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.
Out of curiosity, can the value be an object if (for instance) there's an icon to be displayed with the label and in the selected state? I assume this could be also an iteration
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'm assuming you mean like Regions selector? If so, I added an example of how to do that via the optional data
property
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.
To clarify, this should already be working for the selected option too? I might be missing something but in Storybook it doesn't seem like the flag gets displayed upon selecting an option.
)} | ||
renderOption={(props, option: OptionsType, { selected }) => { | ||
return ( | ||
<li {...props}> |
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 we just pass the props we need here?
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.
We're type-checking that only list item properties are applied here, I'd rather keep it for flexibility.
Yes, I thought about this too! The existing |
Great work! |
Sorry @tyler-akamai been making major changes to this PR, I'm going to close out-of-date comments, but looking forward to your review when I put it up again! |
packages/manager/src/features/Linodes/LinodeSelect/LinodeSelect.tsx
Outdated
Show resolved
Hide resolved
There's still a lot more unit tests we can write for this. I may tackle writing them in a separate PR due to my time constraints or someone on the team can pick that up. Ready for review again! 🚀 |
25f5e57
to
b89430d
Compare
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.
This is looking good based on my testing 🎉
We discussed on Friday during the group review/testing that some improvements can be made for the types (e.g. the one marked TODO
in Autocomplete.tsx
), but I think that could be done in a follow-up PR or iteratively as we implement this component in the app.
sx, | ||
} = props; | ||
|
||
const [inputValue, setInputValue] = React.useState(''); |
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.
To clarify, this should already be working for the selected option too? I might be missing something but in Storybook it doesn't seem like the flag gets displayed upon selecting an option.
Added a storybook example for having separate options as opposed to using @dwiley-akamai Adding flags to the value is not something we can do easily given the types we're restricted to. This may be one tradeoff unless we do a customized input. |
Looks great but I have some general concerns about the typesafety of this component.
None of this stuff is easy but I propose we try to align our component more with MUI's implementation
|
@@ -662,7 +667,6 @@ export const lightTheme: ThemeOptions = { | |||
backgroundColor: 'transparent', | |||
color: primaryColors.main, | |||
}, | |||
padding: 12, |
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.
This was a bug that prevented the IconButton
size
prop from working properly. There should be no regressions since we default to the large size which has a padding of 12
by default. https://github.com/linode/manager/pull/9497/files#diff-f767369a01cd40921dc0da8dac44cf6777e3c155f3680aa2990be0da93c2dc48R659
Thanks @bnussman-akamai for the review and providing an alternative solution 🎉 |
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 think this is a great starting point! 🎉 We can refine this component as we use it and see what changes it may need
Description 📝
We want to enhance accessibility and streamline our use of third-party libraries by eliminating our reliance on
react-select
. This leverages a customized version of MUI Autocomplete which will enable us to gradually replace occurrences ofEnhancedSelect
across our entire codebase.Major Changes 🔄
Backups
andClone Linode
UI to an Autocomplete.LinodeSelect.styles
toAutocomplete.styles
since they made more sense there.Select All
featureTODO
renderOptions
by maybe being more explicit as to what can be passed inPreview 📷
autocomplete-multiple.mov
How to test 🧪