Repository navigation
fix: consolidate conditional class reactivity on attribute derives - #122
Merged
Merged
Conversation
Asking whether the class-toggle injection was overfitted to boolean conditions surfaced something worse: pattern 5 (toggle injection) and pattern 7 (reactive attribute derives) were BOTH claiming the same class expressions, and for list-form classes — the canonical Phoenix idiom — the derive's client value is a JS array that el.className coerced to a comma-joined string, breaking every class on the element after the first optimistic update. Consolidation: - data-lavash-attr-class now normalizes arrays with Phoenix class-list semantics (flatten, drop non-strings, space-join) — the load-bearing fix, pinned by a browser e2e whose compound selectors fail under comma-joining - pattern 5 injection is retired: conditional class expressions of any shape (pure if, list, concat, comparisons — no boolean restriction) ride attribute derives, one general mechanism - data-lavash-toggle remains supported as a hand-written annotation for places the pipeline can't reach (component calls like <.form>, non-lavash templates); its JS is unchanged - pattern 6 (member) stays: chip rows live inside :for loops where attr derives are correctly skipped Demo: manual toggle sites now express conditionals in the class attr itself (fixing their dead renders — the checkout card highlight used to server-render the unselected border regardless of state), all 9 manual data-lavash-visible attrs are gone (one was inverted and saved only by JS pass ordering), and the payment-form condition uses the @is_card_payment boolean. Closes #110. Closes #111.
pinetops
force-pushed
the
feat/mixed-class-toggle
branch
from
August 21, 2026 18:10
02f7afe to
fb0d1a5
Compare
This was referenced Aug 21, 2026
…118) The layer-4 annotation section now documents the post-consolidation reality: the auto-injected set (including attribute derives as THE general mechanism, and select/textarea binds), the HTML-tags-only injection boundary, and each hand-written escape hatch with its reason for existing: - display: async render blocks + non-lavash templates only — for sync fields there is no gap (transpilable non-bare expressions become subtree derives; untranspilable ones are compile errors under optimistic strictness, verified while writing this) - toggle: component calls + non-lavash templates - action: Enter-commit inputs (mints append ids) - id: row identity / provisional marking - valid: custom validity calc override - manual: full opt-out Also records the form-field footgun: a hand-written bind SUPPRESSES the rest of the shorthand injection.
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.
Closes #110. Closes #111. Closes #118.
Reworked after design review
Originally this PR generalized the class-toggle parser (list/concat/unless forms). Review question — "are we overfitting to the boolean condition?" — surfaced something better and something worse:
class={…}expression into a derive that recomputes the attribute client-side. Arbitrary conditions included — no boolean restriction needed anywhere.el.className = arraycomma-joins — breaking every class on the element at the first optimistic update. The special case was hiding the general case's bug — same lesson as the audit.The consolidation
data-lavash-attr-classis now array-aware: Phoenix class-list semantics (flatten, drop non-strings, space-join). Pinned by a browser e2e whose compound selectors (.static-class.on-class) fail under comma-joining.data-lavash-togglestays as manual API (JS unchanged) for places the pipeline can't reach: component calls (<.form>), non-lavash templates.:forloops where attr derives are correctly skipped.Demo
Manual toggle sites now express conditionals in the class attr itself — fixing their dead renders (the checkout card highlight used to server-render the unselected border regardless of payment method). All 9 manual
data-lavash-visibleattrs deleted (one was inverted, saved only by JS pass ordering).<.form>keeps a commented manual toggle (component-call gap, #123).Full hook chain green: 915 root tests (incl. new e2e), 83 demo tests.
🤖 Generated with Claude Code