Skip to content

Commit 79570fa

Browse files
authored
fix: Always set an appName if the app list is populated (#123)
* fix: Always set an appName if the app list is populated The VSCodeDropdown component can't show an empty selection if it has any options. Since the app list is populated after a fetch, the dropdown will default to selecting the first element even if appName in state is an empty string. [DEVX-3070] * Update comment for clarity
1 parent acec944 commit 79570fa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

webview-ui/test-generation/src/state.ts

+8
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,16 @@ export const reducer = (current: State, action: Action): State => {
374374
apps.sort((a, b) => a.name.localeCompare(b.name));
375375
}
376376

377+
// NOTE: Since the VSCodeDropdown can't show an empty selection if its not empty,
378+
// avoid assigning an empty string to appName when the apps list is not empty.
379+
let appName = current.appName;
380+
if (apps.length > 0 && appName === '') {
381+
appName = apps[0].name;
382+
}
383+
377384
return {
378385
...current,
386+
appName,
379387
apps: apps,
380388
};
381389
}

0 commit comments

Comments
 (0)