Skip to content

Commit

Permalink
fix: 'Oh snap' error when creating VPC from Linode Create (linode#10783)
Browse files Browse the repository at this point in the history
* add undefined checker

* this should do it

* fixed still existing regression + maintained Edit Config behavior, still some weird flicker

* add back in clearIcon prop

* Update packages/manager/src/features/Linodes/LinodesCreate/VPCPanel.tsx

Co-authored-by: Hussain Khalil <122488130+hkhalil-akamai@users.noreply.github.com>

---------

Co-authored-by: Hussain Khalil <122488130+hkhalil-akamai@users.noreply.github.com>
  • Loading branch information
coliu-akamai and hkhalil-akamai authored Aug 14, 2024
1 parent 5a40625 commit 86d27c2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/manager/src/features/Linodes/LinodesCreate/VPCPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export const VPCPanel = (props: VPCPanelProps) => {
);
}, [vpcs, region, fromLinodeCreate]);

const defaultVPCValue = fromLinodeConfig ? null : vpcDropdownOptions[0];

const subnetDropdownOptions: DropdownOption[] =
vpcs
.find((vpc) => vpc.id === selectedVPCId)
Expand Down Expand Up @@ -198,9 +200,6 @@ export const VPCPanel = (props: VPCPanelProps) => {
<Stack>
<Typography>{getMainCopyVPC()}</Typography>
<Autocomplete
isOptionEqualToValue={(option, value) => {
return option.label === value.label;
}}
onChange={(_, selectedVPC) => {
handleSelectVPC(selectedVPC?.value || -1);
// Track clearing and changing the value once per page view, configured by inputValue in AA backend.
Expand All @@ -227,12 +226,11 @@ export const VPCPanel = (props: VPCPanelProps) => {
selectedVPCId && selectedVPCId !== -1
? vpcDropdownOptions.find(
(option) => option.value === selectedVPCId
)
: null
) ?? null
: defaultVPCValue
}
autoHighlight
clearIcon={null}
defaultValue={fromLinodeConfig ? null : vpcDropdownOptions[0]} // If we're in the Config dialog, there is no "None" option at index 0
disabled={!regionSupportsVPCs}
errorText={vpcIdError ?? vpcError}
label={from === 'linodeCreate' ? 'Assign VPC' : 'VPC'}
Expand Down

0 comments on commit 86d27c2

Please sign in to comment.