-
Notifications
You must be signed in to change notification settings - Fork 467
fix: #6397 - Inconsistent feature toggle behavior corrected #6601
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
base: main
Are you sure you want to change the base?
Conversation
Inconsistent feature toggle behavior fixed by preventing event bubbling
|
@Mythindia is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
| <div | ||
| onClick={(e) => { | ||
| e.stopPropagation() | ||
| }} | ||
| > | ||
| <Switch | ||
| disabled={!permission || isReadOnly || isLoading} | ||
| data-test={`feature-switch-${index}${ | ||
| displayEnabled ? '-on' : '-off' | ||
| }`} | ||
| checked={displayEnabled} | ||
| onChange={onChange} | ||
| /> | ||
| </div> |
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.
Could you please check the indentation in here ?
talissoncosta
left a comment
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.
Thanks for your contribution. I've just added a minor comment.
Inconsistent feature toggle behavior fixed by preventing event bubbling
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #6397
Inconsistent feature toggle behavior based on window size
Description:
Full-width screens: Clicking the feature toggle switch displays a confirmation modal (correct behavior)
Narrow screens: Clicking the feature toggle switch opens the feature detail view instead of showing the confirmation modal (incorrect behavior)
Root Cause:
The feature flag list component (FeatureRow.tsx) had two responsive rendering branches:
Large screens (d-lg-flex): The toggle Switch was properly wrapped with onClick={(e) => { e.stopPropagation() }} to prevent event bubbling
Narrow screens (d-lg-none): The toggle Switch was missing this event propagation blocker
When users clicked the toggle on narrow screens, the click event bubbled up to the parent row's onClick={() => editFeature()} handler, which opened the feature detail view instead of allowing the toggle confirmation modal to appear.
Solution
Event Propagation Handler (FeatureRow.tsx)
Added onClick={(e) => { e.stopPropagation() }} wrapper around the narrow-screen Switch component to prevent click events from bubbling to the parent row's click handler.
How did you test this code?
Open your browser (in my case chromium-based) at half-width
Click the toggle to enable/disable a feature in the dashboard
Notice how it opens the feature in a new view