Skip to content

Fix date picker crashing when used with clearable#2591

Merged
joshhanley merged 1 commit intomainfrom
josh/fix-undefined-iconvariant-in-input-sub-components
Apr 23, 2026
Merged

Fix date picker crashing when used with clearable#2591
joshhanley merged 1 commit intomainfrom
josh/fix-undefined-iconvariant-in-input-sub-components

Conversation

@joshhanley
Copy link
Copy Markdown
Member

The Scenario

Rendering a flux:date-picker with a clearable trigger throws:

ErrorException
Undefined variable $iconVariant

packages/flux/stubs/resources/views/flux/input/clearable.blade.php:22
<flux:date-picker wire:model="agreement_date" label="Agreement date">
    <x-slot name="trigger">
        <flux:date-picker.input clearable />
    </x-slot>
</flux:date-picker>

Any code that renders flux:input.clearable, flux:input.viewable, flux:input.copyable, or flux:input.expandable directly (rather than via a flux:input) hits the same error.

The Problem

#2566 switched the four input action sub-components from hard-coded icon variants (variant="micro" / variant="mini") to :variant="$iconVariant", and updated flux:input to forward :$iconVariant into each one.

Because flux:input always passes iconVariant down, the sub-components receive it as a variable and render fine in that path. But the sub-components themselves never declared iconVariant in @props — so they only work when a parent explicitly passes it.

flux:date-picker.input's native variant renders the clear button via:

{{-- packages/flux-pro/stubs/resources/views/flux/date-picker/input/variants/native.blade.php --}}
<flux:input.clearable :$size as="div" />

iconVariant isn't passed, isn't declared, isn't defined, and rendering blows up.

The Solution

Declare iconVariant (and size, for the same reason) as props with sensible defaults on each of the four sub-components:

@props([
    'iconVariant' => 'mini',
    'size' => null,
])

mini matches the default on flux:input, so behaviour is unchanged when the sub-components are used via flux:input. Anywhere they're used standalone — flux:date-picker.input internally, or user code calling them directly — now falls through to the default and renders cleanly.

size had to be declared alongside iconVariant because once @props is present, Blade stops auto-exposing undeclared attributes as variables, which broke the existing $size === 'sm' checks.

Fixes #2590

Declare `iconVariant` and `size` as props on the four input action sub-components
(`clearable`, `viewable`, `copyable`, `expandable`) so they render cleanly when
used standalone — e.g. by `flux:date-picker.input`, which calls `flux:input.clearable`
directly without passing `iconVariant`.
@joshhanley joshhanley merged commit 44f240e into main Apr 23, 2026
@joshhanley joshhanley deleted the josh/fix-undefined-iconvariant-in-input-sub-components branch April 23, 2026 23:00
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.

v2.14.0 breaks date picker

1 participant