Skip to content

Commit d1bc5f9

Browse files
committed
fix: always sync compiler dropdowns to redux state
Set the vscode-single-select value unconditionally in the sync effects so the dropdown reflects redux state even when the level is empty (e.g. transiently while switching projects), instead of keeping the previous project's selection. Addresses PR review feedback on #1655.
1 parent bd5c7c6 commit d1bc5f9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/project-settings/assets/compiler/features/CompilerConfigurationView.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,21 @@ const CompilerConfigurationView = (): JSX.Element | null => {
111111
useSelectChange(sourceRef, onChangeSourceLevel);
112112
useSelectChange(targetRef, onChangeTargetLevel);
113113

114-
// Keep the rendered selection in sync with the redux state.
114+
// Keep the rendered selection in sync with the redux state. Set the value
115+
// unconditionally (even when the level is "") so the dropdown always reflects
116+
// state instead of keeping the previous project's selection.
115117
useEffect(() => {
116-
if (complianceRef.current && complianceLevel) {
118+
if (complianceRef.current) {
117119
(complianceRef.current as any).value = complianceLevel;
118120
}
119121
}, [complianceLevel, availableComplianceLevels]);
120122
useEffect(() => {
121-
if (sourceRef.current && sourceLevel) {
123+
if (sourceRef.current) {
122124
(sourceRef.current as any).value = sourceLevel;
123125
}
124126
}, [sourceLevel, availableComplianceLevels]);
125127
useEffect(() => {
126-
if (targetRef.current && targetLevel) {
128+
if (targetRef.current) {
127129
(targetRef.current as any).value = targetLevel;
128130
}
129131
}, [targetLevel, availableComplianceLevels]);

0 commit comments

Comments
 (0)