Skip to content

Commit aa415f7

Browse files
committed
fix: Support query for ViewButton options string
Solves #7566
1 parent 29b38b4 commit aa415f7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Panel/Ui/Buttons/ViewButton.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,17 @@ public static function normalize(array $button): array
165165
public function props(): array
166166
{
167167
// helper for props that support Kirby queries
168-
$resolve = fn ($value) =>
168+
$resolve = fn (string|null $value) =>
169169
$value ?
170170
$this->model?->toSafeString($value) ?? $value :
171171
null;
172172

173+
$options = $this->options;
174+
175+
if (is_string($options) === true) {
176+
$options = $resolve($options);
177+
}
178+
173179
return [
174180
...$props = parent::props(),
175181
'dialog' => $resolve($props['dialog']),
@@ -178,7 +184,7 @@ public function props(): array
178184
'link' => $resolve($props['link']),
179185
'text' => $resolve($props['text']),
180186
'theme' => $resolve($props['theme']),
181-
'options' => $this->options
187+
'options' => $options
182188
];
183189
}
184190

tests/Panel/Ui/Buttons/ViewButtonTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ public function testPropsWithQueries(): void
212212
model: $model,
213213
text: 'Page: {{ page.url }}',
214214
link: 'https://getkirby.com/{{ page.slug }}',
215+
options: 'my/options/{{ page.slug }}'
215216
);
216217

217218
$props = $component->props();
218219
$this->assertSame('Page: /test', $props['text']);
219220
$this->assertSame('https://getkirby.com/test', $props['link']);
221+
$this->assertSame('my/options/test', $props['options']);
220222
}
221223

222224
public function testResolve(): void

0 commit comments

Comments
 (0)