-
-
Notifications
You must be signed in to change notification settings - Fork 381
Description
Hello,
I have the following fairly simple LiveComponent with 2 LiveProp
s with url: true
(only relevant part kept):
#[AsLiveComponent(template: 'components/date_selector.html.twig')]
final class DateSelector
{
use DefaultActionTrait;
use ComponentToolsTrait;
#[LiveProp(writable: true, format: 'Y-m-d', url: true)]
public ?CarbonImmutable $start = null;
#[LiveProp(writable: true, format: 'Y-m-d', url: true)]
public ?CarbonImmutable $end = null;
#[LiveAction]
public function setRange(#[LiveArg] string $preset): void
{
$today = CarbonImmutable::today();
switch ($preset) {
case 'today':
$this->start = $today->startOfDay();
$this->end = $today->endOfDay();
break;
case 'this_month':
$this->start = $today->startOfMonth()->startOfDay();
$this->end = $today->endOfMonth()->endOfDay();
break;
}
}
}
This component is rendered in my property_show
route (this is important for later), like so:
<twig:DateSelector></twig:DateSelector>
, again nothing fancy.
The component itself has the following template (relevant parts only):
<div {{ attributes }}>
<div class="btn-group mb-3" role="group" aria-label="Date shortcuts">
<button class="btn {{ this.matchesPreset('today') ? 'btn-primary' : 'btn-outline-primary' }} btn-sm"
{{ live_action('setRange', { preset: 'today' }) }}>
Today
</button>
<button class="btn {{ this.matchesPreset('this_month') ? 'btn-primary' : 'btn-outline-primary' }} btn-sm"
{{ live_action('setRange', { preset: 'this_month' }) }}>
This Month
</button>
</div>
</div>
Just 2 buttons to select a preset date.
Before upgrading to 2.29 from 2.27 (0 code has been changed on my end between both versions):

This used to work perfectly: the date was correctly set in the component AND the URL was updated to reflect the new values, as expected.
On the latest version though, the date is still correctly set in the component but the URL is never updated.
After doing some digging, I get an exception in Symfony\UX\LiveComponent\Util\UrlFactory
line 42:

The exception is:
Some mandatory parameters are missing ("property") to generate a URL for route "property_show".
It's complaining that it's unable to regenerate the route where the component is rendered in because of a missing parameter.
It is indeed missing that parameter, but that's because the component does not need or care about it. Components should (and used to) be able to change the query part of the URL without regenerating the full URL page.
I know this piece of code has been changed a few times over the latest versions (by @Kocal and @mbuliard most recently), looks like something got broken in the middle.
Let me know if i can help more, for now I have reverted to 2.27
Thanks and keep up the good work, awesome components to work with!