Refactor suffix rendering logic in flux:menu.item component#2630
Refactor suffix rendering logic in flux:menu.item component#2630ghabriel25 wants to merge 1 commit into
flux:menu.item component#2630Conversation
|
@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 |
|
@joshhanley It's okay. This refactor just following how other components handle conditional slot/text |
|
@ganyicz Thanks! |
calebporzio
left a comment
There was a problem hiding this comment.
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!

Just a tiny refactor for
flux:menu.itemBefore
After
File Changed
stubs/resources/views/flux/menu/item.blade.php