laravel / folio

Page based routing for Laravel.
MIT License
568 stars 46 forks source link

Top level components are not receiving parameter values #58

Closed farez closed 1 year ago

farez commented 1 year ago

Folio Version

1.0.0-beta.1

Laravel Version

10.16.1

PHP Version

8.1

Description

Not sure if this is a bug or not, but if a view component is used inside a Folio page as the 'top level' component, e.g. as a layout component, parameters do not get passed to the component. But it does get passed through once it's nested inside another div.

E.g. this doesn't pass the title parameter:

<x-app-layout title="Videos">

   ...

</x-app-layout>

But this does:

<div>
    <x-app-layout title="Videos">

        ...

    </x-app-layout>
</div>

Steps To Reproduce

  1. Create a component that accepts a parameter and outputs it in the component.
  2. Use the component inside a Folio page as the top-level component. Pass along the parameter.
  3. Result: the parameter's value is not passed to the component.
  4. Now, in the Folio page, wrap the component with div tags.
  5. Refresh the output.
  6. Result: the parameter's value is now passed to the component.
nunomaduro commented 1 year ago

You need to set your title like so:

<x-app-layout>
    <x-slot:title>
        Videos
    </x-slot>

    ...
</x-app-layout>
farez commented 1 year ago

That works, thanks!