-
Notifications
You must be signed in to change notification settings - Fork 358
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: 'Oh snap' error when creating VPC from Linode Create #10783
Conversation
@@ -227,7 +227,7 @@ export const VPCPanel = (props: VPCPanelProps) => { | |||
selectedVPCId && selectedVPCId !== -1 | |||
? vpcDropdownOptions.find( | |||
(option) => option.value === selectedVPCId | |||
) | |||
) || 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.
Originally, I'd changed line 202 to be return option.label === value?.label;
, since the bug is caused by the value being undefined. I thought that would be a super quick fix 😅 but this led to two MUI errors:
- controlled changing to uncontrolled input error
- "The value provided to Autocomplete is invalid. None of the options match with
undefined
."
ngl it took me a hot second to remember that array.find can return an undefined value oops 😅 so this change ensures that the item being passed to the value prop is always 'null' or some vpc dropdown option, not undefined. This fixes both the original problem and gets rid of the two MUI warnings above too!
This originally slipped past likely because the value prop is an optional parameter, so it can technically still be undefined (but we won't be passing it an undefined value).
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've also been trying to play around with making it look cleaner so if anyone has suggestions lmk 😆)
I see a few regressions still that we'll want to address
I'm thinking we can delete the value={
selectedVPCId && selectedVPCId !== -1
? vpcDropdownOptions.find(
(option) => option.value === selectedVPCId
)
: vpcDropdownOptions[0]
Linode Create v2 handles the "empty" state better by using a placeholder instead of a "None" option, but I think these steps will get Linode Create v1 back to what is use to be |
…ill some weird flicker
This field was a point of trouble in the original PR too. Linking for context in case you hadn't read. |
oh man, thanks for pointing that out @mjac0bs! I'm gonna add back in the |
Coverage Report: ✅ |
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.
Great catch and thanks for addressing this promptly! Verified VPCPanel
works as expected across the app.
packages/manager/src/features/Linodes/LinodesCreate/VPCPanel.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Hussain Khalil <122488130+hkhalil-akamai@users.noreply.github.com>
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 good!
I still think clearIcon
is a "hack" for not using disableClearable
from a type safety perspective, but this seems to be working alright. It might require a bit more work in the future to dial this in
Description 📝
When the Linode Create v2 feature flag is not checked, trying to create a VPC from Linode Create results in the page crashing
Changes 🔄
Target release date 🗓️
8/14 - trying to get it into this upcoming release, as the bug it fixes is still unreleased!
Preview 📷
How to test 🧪
Reproduction steps
Verification steps
As an Author I have considered 🤔
Check all that apply
Commit message and pull request title format standards
<commit type>: [JIRA-ticket-number] - <description>
Commit Types:
feat
: New feature for the user (not a part of the code, or ci, ...).fix
: Bugfix for the user (not a fix to build something, ...).change
: Modifying an existing visual UI instance. Such as a component or a feature.refactor
: Restructuring existing code without changing its external behavior or visual UI. Typically to improve readability, maintainability, and performance.test
: New tests or changes to existing tests. Does not change the production code.upcoming
: A new feature that is in progress, not visible to users yet, and usually behind a feature flag.Example:
feat: [M3-1234] - Allow user to view their login history