Skip to content

Refactor suffix rendering logic in flux:menu.item component#2630

Open
ghabriel25 wants to merge 1 commit into
livewire:mainfrom
ghabriel25:remove-uneccessary-check
Open

Refactor suffix rendering logic in flux:menu.item component#2630
ghabriel25 wants to merge 1 commit into
livewire:mainfrom
ghabriel25:remove-uneccessary-check

Conversation

@ghabriel25

Copy link
Copy Markdown
Contributor

Just a tiny refactor for flux:menu.item

Before

image

After

image

File Changed

  • stubs/resources/views/flux/menu/item.blade.php

@joshhanley

Copy link
Copy Markdown
Member

@ghabriel25 thanks for the PR! Personally, I prefer the before as I find it easier to read 😅 mainly because I know nothing in that block will happen if there is no suffix. But let's see what Caleb thinks

@ghabriel25

ghabriel25 commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@joshhanley It's okay. This refactor just following how other components handle conditional slot/text

@ganyicz

ganyicz commented May 28, 2026

Copy link
Copy Markdown
Collaborator

A more compelling argument here would be that the component renders more correctly now.

Before, the truthiness check would disregard the suffix if the value is 0 string.

SCR-20260528-inai

@ghabriel25

Copy link
Copy Markdown
Contributor Author

@ganyicz Thanks!

@calebporzio calebporzio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ghabriel25! I ran this through a real render comparison (fresh Laravel app, Flux as a path repo, DOM-diffed menu.item output on main vs this branch) across: no suffix, string suffix, kbd, and a suffix slot. Output is byte-identical in every case except one:

  • suffix="0" — previously swallowed by the truthiness check, now renders. As @ganyicz pointed out, that's a correctness win, not a regression.

I also like that this now mirrors the is_string($x) && $x !== '' shape the $icon and $iconTrailing blocks in this same file already use, so the file reads consistently top to bottom.

I hear Josh on the readability of the original nesting, but consistency with the surrounding blocks plus the "0" fix tips it for me. Appreciate the tidy-up!

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.

4 participants