Skip to content

@aware does not resolve dynamic parent attributes during fold compilation #171

@mr-riabov

Description

@mr-riabov

Blaze Version

v1.0.11

Flux Version

v2.13.1

Livewire Version

v4 (latest)

PHP Version

8.4

Description

PR #135 fixed @aware propagation through fold+delegate boundaries for static attribute values. However, dynamic (:binding) attributes on a parent component are not resolved by @aware in
folded child components.

When Blaze fold compiles <flux:select.option>, it evaluates @aware(['indicator']) at compile time. If the parent <flux:select> has a static indicator="checkbox", the fold correctly resolves it
and compiles the checkbox variant. But if the parent uses a dynamic binding like :indicator="$multiple ? 'checkbox' : null", Blaze cannot evaluate the PHP expression at compile time, so $indicator
falls back to null and the check (default) variant is baked into the static HTML output.

At runtime, pushData() correctly pushes the resolved indicator value onto the data stack, but the folded HTML is already static — no getConsumableData('indicator') call remains in the compiled
output.

Steps to Reproduce

  1. Create a Blade component with a dynamic indicator binding:
@props(['multiple' => false])

<flux:select
    variant="listbox"
    :multiple="$multiple"
    :indicator="$multiple ? 'checkbox' : null"
>
    <flux:select.option value="1">Option 1</flux:select.option>
    <flux:select.option value="2">Option 2</flux:select.option>
</flux:select>

2. Use the component with multiple:
<x-my-select :multiple="true" />

3. Inspect the compiled Blaze output in storage/framework/views/.

Expected Behavior

The <flux:select.option> should render with the checkbox indicator variant (a bordered div with check + minus SVGs).

Actual Behavior

The option renders with the default check indicator (a single checkmark SVG icon), because @aware(['indicator']) resolves to null at fold compile time.

Compiled Output Evidence

Dynamic :indicator (broken) — compiled option uses check variant:
<svg class="... hidden [ui-option[data-selected]_&]:block" viewBox="0 0 20 20">
  <path d="M16.704 4.153a.75..."/>  <!-- single check icon -->
</svg>

Static indicator="checkbox" (works) — compiled option uses checkbox variant:
<div class="shrink-0 size-[1.125rem] rounded-[.3rem] ... border ...">
    <svg viewBox="0 0 16 16"><!-- check --></svg>
    <svg viewBox="0 0 16 16"><!-- minus --></svg>
</div>

Workaround

Use a static indicator="checkbox" instead of a dynamic :indicator binding. This limits the component's flexibility but works with the current fold implementation.

Possible Fix

Option A: Add 'indicator' to the unsafe array in flux/select/index.blade.php so Blaze keeps it as a runtime value instead of folding it away.

Option B: When fold encounters an @aware prop whose parent value is a dynamic PHP expression, defer its resolution to runtime (emit a getConsumableData() call) instead of baking in the default value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions