Fix SF color button state sync and touch event handling - #232
Conversation
…r change Picker mode panel only stopped click/mousedown propagation, so on touch devices the pointerdown/touchstart bubbled to document and Bricks' outside- interaction handling dismissed the panel before the swatch click landed — closing it with nothing written to the input. Extend the propagation guard to pointerdown/touchstart. The SF button dot was armed from the live input value only on fresh injection, so picking a colour through Bricks' own palette (which leaves our foreign button in place) left a stale SF swatch. Sync the dot state on every reconcile pass, resetting to the default colourful dot when the value is no longer an --sf-color-* variable.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR improves the SF color picker UI in the Bricks editor by fixing event propagation in the color panel dialog and refactoring the SF color button injector to be reuse-safe and keep the button state synchronized with the current color input. ChangesSF Color Picker UI
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
This PR improves the reliability of the SLASHED color button in the Bricks editor by ensuring its visual state stays synchronized with the color input value across all change paths, and adds proper touch event handling to the color panel.
Key Changes
Refactored button state management: Extracted the logic for syncing the SF button's dot appearance into a new
syncSFButtonState()function that is called on everyinjectSFButton()pass, not just on initial creation. This ensures the button's visual state reflects the current input value even when the color changes through paths that don't tear out the button (e.g., Bricks' own color palette, dynamic data, manual edits).Improved button creation logic: Changed from an early return when the button already exists to a conditional creation pattern. The button is now only created once, but its state is always synchronized with the live input value.
Enhanced dot state reset: The dot now properly resets to its default colourful conic-gradient appearance when the input no longer contains a recognized
--sf-color-*variable, preventing stale SF swatches from persisting after picking colors through Bricks' own UI.Added touch event handling: Added
onpointerdownandontouchstartevent handlers to the color panel to prevent event propagation, ensuring consistent behavior across mouse, pointer, and touch interactions.Implementation Details
The
syncSFButtonState()function now handles both the active state (when a known SF color variable is present) and the inactive state (resetting styles when the variable is no longer recognized). This makes the button's appearance a true reflection of the current input value rather than a snapshot from when the button was created.https://claude.ai/code/session_01HTA4dAMyd66yL6BAm7vWcu
Summary by CodeRabbit