fix: keep browser history intact when navigating between cards view and participant form
This commit is contained in:
+10
-2
@@ -121,10 +121,11 @@ trait HxTrait
|
||||
* @param string $templateName The name of the Twig template
|
||||
* @param string[] $blockNames An array of block names to render
|
||||
* @param array<string, mixed> $context The context to pass to the template
|
||||
* @param string|null $pushUrl Optional URL to push to browser history
|
||||
*
|
||||
* @return Response Response containing all rendered blocks with OOB context
|
||||
*/
|
||||
protected function htmxOobResponse(string $templateName, array $blockNames, array $context = []): Response
|
||||
protected function htmxOobResponse(string $templateName, array $blockNames, array $context = [], ?string $pushUrl = null): Response
|
||||
{
|
||||
$html = '';
|
||||
// Add a flag to the context so templates can conditionally add the hx-swap-oob attribute.
|
||||
@@ -135,6 +136,13 @@ trait HxTrait
|
||||
$html .= $this->renderBlockView($templateName, $blockName, $oobContext);
|
||||
}
|
||||
|
||||
return new Response($html);
|
||||
$response = new Response($html);
|
||||
|
||||
// Set HX-Push-Url header if URL is provided
|
||||
if (null !== $pushUrl) {
|
||||
$response->headers->set('HX-Push-Url', $pushUrl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user