Skip to content

fix(fab): fan out the first fab-flower action when no main-action is set#4560

Open
JamBalaya56562 wants to merge 2 commits into
saadeghi:v5.6from
JamBalaya56562:fix/4531-fab-flower-first-action
Open

fix(fab): fan out the first fab-flower action when no main-action is set#4560
JamBalaya56562 wants to merge 2 commits into
saadeghi:v5.6from
JamBalaya56562:fix/4531-fab-flower-first-action

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #4531

Problem

In .fab-flower the center pin was > *:nth-child(-n + 2) { --position: 0rem; }, which pinned both the trigger (1st child) and the first action (2nd child) to the center. So when no .fab-main-action / .fab-close is present, the first action button overlaps and "replaces" the trigger instead of fanning out into the quarter-circle arc.

As reported by @topherfangio, this should only happen when a button is explicitly marked .fab-main-action. (@saadeghi: "You're right. Will be fixed in v5.6 soon.")

Fix (minimal / additive)

Following review (@pdanpdan, @saadeghi) the change is kept as small and additive as possible:

  1. Center by identity, not position — pin the trigger plus .fab-main-action / .fab-close (> *:nth-child(1), > .fab-main-action, > .fab-close).
  2. The existing arc blocks (:has(:nth-child(3..6))) are left untouched — Mode A (with a main-action/close) is byte-identical to v5.6, so there is no regression risk.
  3. A single block is appended for the no-main-action case: &:not(:has(.fab-main-action, .fab-close)), mirroring the existing degrees shifted by one child (the arc starts at the 2nd child) and hiding :nth-child(n + 6) so it caps at the same 4 actions as Mode A.

Net diff vs v5.6 is just the identity-pin line + the appended :not(:has()) block. (An earlier revision wrapped the existing rules in :has(.fab-main-action)/:has(.fab-close); that wrapping has been reverted.)

Playground

▶️ Before / after, side by side: https://play.tailwindcss.com/LifJWa8hZG

Rows are action counts, left column is the released (buggy) daisyUI, right column is this PR. Heads-up: Play loads the released daisyUI, so the right column re-creates the fix's result with a clearly-labelled preview shim on top of it — that shim is more verbose than this PR (it has to override the released @layer rules). The real CSS is the small diff above.

Verification

bun run build succeeds (lightningcss accepts the :not(:has()) selectors) and bun test passes (86/86).

Headless-Chromium measurement of each action's center offset from the trigger (button = 48px), opening each FAB via :focus-within:

case trigger center button arc actions (dist @ angle)
no main / 1 0px A 67px @135°
no main / 2 0px A, B 67px @165° / 105°
no main / 3 0px A, B, C 86px @180° / 135° / 90°
no main / 4 0px A, B, C, D 106px @180° / 150° / 120° / 90°
fab-main-action / 3 0px 0px (centered) A, B, C 86px @180° / 135° / 90°
fab-close / 3 0px 0px (centered) A, B, C 86px @180° / 135° / 90°
  • Without a main-action the first action goes from overlapping the trigger (dist 0) to fanning out (dist > 0) at the correct angles.
  • With fab-main-action / fab-close the center button stays on the trigger and the arc matches the unchanged v5.6 geometry.

Notes

  • Single-component change in packages/daisyui/src/components/fab.css, plus a docs example (fab-flower without a main action) and a capacity note.

🤖 Generated with Claude Code

In .fab-flower the center pin used `:nth-child(-n + 2)`, which forced BOTH the
trigger and the first action to the center — so without an explicit
.fab-main-action / .fab-close, the first action overlapped (and "replaced") the
trigger instead of fanning out into the arc.

Pin the center by identity (the trigger plus .fab-main-action / .fab-close) and
split the arc geometry into two modes: with a main-action/close the arc starts
at the 3rd child (unchanged); without one, the first action (2nd child) also
fans out, with the per-count degree distribution shifted accordingly (up to 5
actions). Also document the optional-main-action behaviour with a new example.

Closes saadeghi#4531

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
JamBalaya56562 added a commit to JamBalaya56562/daisyui that referenced this pull request Jun 17, 2026
…tion) submitted to v5.6

Add saadeghi#4531 to the implementation-history table with PR saadeghi#4560, the Tailwind
Play demo (https://play.tailwindcss.com/16jkNZOdsE) and the headless
before/after result (first action overlap d:0 -> 1.4+); annotate its detail
subsection as PR-submitted/awaiting merge (was held for the maintainer, who
deferred it to v5.6 but had not implemented it); update the remaining-count
note; and add saadeghi#4531 to the headless visual-verification track record.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saadeghi saadeghi self-assigned this Jun 17, 2026
@pdanpdan

Copy link
Copy Markdown
Contributor

Hello.

I would say that the solution is a little bit convoluted.
I would go with:

  • apply --position: 0rem; only to the FAB button and .fab-main-action and .fab-close (like in PR)
  • keep the current CSS for flower
  • at the end add the styles for &:not(:has(.fab-main-action, .fab-close)) in the same way they are done above - only change the number of children
  • also for this case > :nth-child(n + 6) should be hidden

@saadeghi

Copy link
Copy Markdown
Owner

Thanks for the PR.
I would appreciate if the CSS rule changes stay as minimum as possible. When this many lines are changing in a PR, we have to predict and test every possible situation to make sure it's not breaking existing apps in the next update.

Address review (pdanpdan, saadeghi): instead of wrapping the existing arc
blocks in :has(.fab-main-action) / :has(.fab-close), leave them untouched and
add the no-main-action geometry as a separate
:not(:has(.fab-main-action, .fab-close)) override (existing degrees, shifted by
one child, :nth-child(n + 6) hidden). Mode A CSS is now byte-identical to v5.6,
so the diff is additive and carries no regression risk. The no-main arc caps at
4 actions to match the with-main capacity; docs capacity note updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JamBalaya56562

Copy link
Copy Markdown
Contributor Author

Thanks @pdanpdan and @saadeghi — updated to keep the change minimal and additive, exactly along the lines you suggested:

  • Kept the identity-based center pin (> *:nth-child(1), > .fab-main-action, > .fab-close).
  • Reverted the wrapping of the existing arc blocks — they are now byte-identical to v5.6, so Mode A (with a fab-main-action / fab-close) is completely untouched and carries no regression risk.
  • Appended a single &:not(:has(.fab-main-action, .fab-close)) block, mirroring the existing degrees with the child numbers shifted by one, plus > :nth-child(n + 6) hidden (so the no-main case caps at the same 4 actions as Mode A).

So the net diff vs v5.6 is now just the identity-pin line + that one appended block. Pushed as a new commit, and the description has the headless before/after numbers (no-main fans out, with-main/close stays centered and unchanged). 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants