Skip to content

Commit 80945b5

Browse files
committed
add server-side changed props in request to be handled by LiveUrlSubscriber
1 parent 4a1ec50 commit 80945b5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/LiveComponent/src/EventListener/LiveComponentSubscriber.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,17 @@ public function onKernelView(ViewEvent $event): void
255255
return;
256256
}
257257

258-
$event->setResponse($this->createResponse($request->attributes->get('_mounted_component')));
258+
$mountedComponent = $request->attributes->get('_mounted_component');
259+
if (!$request->attributes->get('_component_default_action', false)) {
260+
// On custom action, props may be updated by the server side
261+
// @todo discuss name responseProps
262+
// @todo maybe always set in, including default action and use only this, ignoring `props` and `updated` for UrlFactory ?
263+
$liveRequestData = $request->attributes->get('_live_request_data');
264+
$liveRequestData['responseProps'] = (array) $mountedComponent->getComponent();
265+
$request->attributes->set('_live_request_data', $liveRequestData);
266+
}
267+
268+
$event->setResponse($this->createResponse($mountedComponent));
259269
}
260270

261271
public function onKernelException(ExceptionEvent $event): void

src/LiveComponent/src/EventListener/LiveUrlSubscriber.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ private function getLivePropsToMap(Request $request): array
7272
$metadata = $this->metadataFactory->getMetadata($componentName);
7373

7474
$liveData = $request->attributes->get('_live_request_data') ?? [];
75-
$values = array_merge($liveData['props'] ?? [], $liveData['updated'] ?? []);
75+
$values = array_merge(
76+
$liveData['props'] ?? [],
77+
$liveData['updated'] ?? [],
78+
$liveData['responseProps'] ?? []
79+
);
7680

7781
$urlLiveProps = [
7882
'path' => [],

0 commit comments

Comments
 (0)