Skip to content

Commit

Permalink
Fix: laggy toggles (#3873)
Browse files Browse the repository at this point in the history
This PR removes the `disabled` state for the feature toggle env
switches.

This is what causes the lag from when you toggle the switch to when it
becomes available for actions again.


Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: Nuno Góis <github@nunogois.com>
  • Loading branch information
2 people authored and gastonfournier committed May 26, 2023
1 parent 9f74007 commit 4bcd73b
Showing 1 changed file with 15 additions and 6 deletions.
Expand Up @@ -134,13 +134,13 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
onChangeRequestToggle(
feature.name,
environmentName,
!value,
!isChecked,
false
);
}
return;
}
if (value) {
if (isChecked) {
await handleToggleEnvironmentOff();
return;
}
Expand All @@ -159,7 +159,12 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
},
});
if (isChangeRequestConfigured(environmentName)) {
onChangeRequestToggle(feature.name, environmentName, !value, true);
onChangeRequestToggle(
feature.name,
environmentName,
!isChecked,
true
);
} else {
await handleToggleEnvironmentOn(true);
}
Expand All @@ -173,7 +178,12 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
},
});
if (isChangeRequestConfigured(environmentName)) {
onChangeRequestToggle(feature.name, environmentName, !value, false);
onChangeRequestToggle(
feature.name,
environmentName,
!isChecked,
false
);
} else {
await handleToggleEnvironmentOn();
}
Expand Down Expand Up @@ -201,7 +211,7 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
>
<PermissionSwitch
tooltip={
value
isChecked
? `Disable feature in ${environmentName}`
: `Enable feature in ${environmentName}`
}
Expand All @@ -211,7 +221,6 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
permission={UPDATE_FEATURE_ENVIRONMENT}
inputProps={{ 'aria-label': environmentName }}
onClick={onClick}
disabled={isChecked !== value}
/>
</StyledBoxContainer>
{showStrategyImprovements && (
Expand Down

0 comments on commit 4bcd73b

Please sign in to comment.