Skip to content

Fix label/slot precedence#2371

Open
ganyicz wants to merge 1 commit intomainfrom
filip/option-label-issue
Open

Fix label/slot precedence#2371
ganyicz wants to merge 1 commit intomainfrom
filip/option-label-issue

Conversation

@ganyicz
Copy link
Collaborator

@ganyicz ganyicz commented Feb 5, 2026

The scenario

A user-land component wrapping Flux components passes a label prop:

<x-select label="Industry" />
{{-- resources/views/components/select.blade.php --}}
@props(['label'])

<flux:select :$label variant="listbox">
    <flux:select.option>Photography</flux:select.option>
    <flux:select.option>Design services</flux:select.option>
</flux:select>

The problem

The label prop leaks from the parent component into all children.

This happens because <flux:delegate-component> forwards inherited data from the entire component stack.

Combined with {{ $label ?? $slot }}, every option displays "Industry".

The solution

Reverse the priority from {{ $label ?? $slot }} to {{ $slot->isNotEmpty() ? $slot : $label }} across 9 files where this pattern occurs. Slot content now wins when present; label prop still works as fallback for self-closing tags.

Risk assessment

  • The $slot->isNotEmpty() pattern is already used elsewhere in the codebase
  • The docs never show both being passed simultaneously
  • Self-closing tags (<flux:radio label="Foo" />) produce an empty slot, so $label is still used as fallback

The problematic pattern would be:

<flux:menu.radio label="Foo">Bar</flux:menu.radio>

Before this change: Renders Foo
After this change: Renders Bar

Flux Pro PR: livewire/flux-pro#436

Fixes #2300

@ganyicz ganyicz changed the title Prefer slot content over label prop to prevent inheritance leaking Fix label/slot precedence Feb 5, 2026
@ganyicz ganyicz marked this pull request as draft February 5, 2026 15:52
@ganyicz ganyicz force-pushed the filip/option-label-issue branch from b840af4 to 828e930 Compare February 6, 2026 10:11
@ganyicz ganyicz force-pushed the filip/option-label-issue branch from 828e930 to e7f6f90 Compare February 6, 2026 10:11
@ganyicz ganyicz marked this pull request as ready for review February 6, 2026 10:13
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.

Wrapped listbox in custom component inherits option label

1 participant