Repository navigation
fix: keep border style changes made while focused - #163
Merged
Merged
Conversation
Route every border style write (SetBorderStyle, WithBorderStyle via Apply, SetClass border colors) through a slot that targets the saved unfocused style while a focus highlight occupies borderStyle, so the highlight stays visible and Blur restores the latest style instead of the one captured at focus time. The class snapshot reads the same slot so clearing a class while focused does not bake the highlight into the base style. Input and TextArea apply their focus color through the same highlight helper, and Blur restores a saved style regardless of an onBlur handler. Fixes #153
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #163 +/- ##
==========================================
+ Coverage 84.49% 84.62% +0.12%
==========================================
Files 169 169
Lines 21535 21537 +2
==========================================
+ Hits 18197 18226 +29
+ Misses 2669 2646 -23
+ Partials 669 665 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
…orderStyle() Blur() now restores the saved style and clears the stash before invoking onBlur, so a handler that refocuses gets a fresh highlight instead of losing it. BorderStyle() reads the same slot SetBorderStyle writes, so it round-trips while the default highlight is showing. The reference doc is updated to say so. The two linear SetClass tests are folded into a table with a new apply-before-focus row, plus a refocus-in-onBlur test.
Owner
Author
|
@greptileai please review again |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changing an element's border color while it was focused was lost on blur. Focus() stashed the border style and swapped in the cyan highlight, but SetBorderStyle, WithBorderStyle applied through Apply, and SetClass with a border color all wrote straight to borderStyle. That replaced the highlight for the rest of the focus period, and Blur() then put back the color captured at focus time, discarding the change. SetClass also snapshotted the highlight as its pre-class value, so clearing the class while focused baked cyan into the base style.
Every border style writer now goes through one slot on Element that points at the saved unfocused style while a highlight is showing and at borderStyle otherwise. The highlight stays visible, and Blur restores whatever was written last. The class snapshot and restore read the same slot. Input and TextArea apply their focus color through the same highlight helper so writes to their rendered root follow the rule. Two behavior changes ride along. A bordered element with an onBlur handler and no onFocus handler used to keep the cyan highlight forever after blur, because Blur skipped the restore whenever onBlur was set; it now restores the unfocused style like any other element, and it does so before calling onBlur so a handler that refocuses gets a fresh highlight. BorderStyle() now returns the unfocused style while the default highlight is showing, matching what SetBorderStyle set, instead of the cyan highlight.
Fixes #153