Having to click action button twice for changes to take place

I have this Button and on click I want to change pdf template

Actions\Action::make('test_smthng') ->label('Change PDF preview') ->action(fn () => $this->selectedView = 'pdf-templates.layout.pdf-preview-default')

and this ViewFIeld that's showing the custom template

protected function getTemplateSection(): Component { return Section::make('PDF Preview') ->schema([ Grid::make(1) ->schema([ ])->columnSpan(1), Grid::make() ->schema([ ViewField::make('preview.default') ->columnSpan(2) ->visible() ->view($this->selectedView)

For some reason when I first click on button it doesn't render the selectedView, but when I click again it does. Any ideas?

I tried dispatching refresh on action $this->dispatch('refresh'); and even directly with setting ID on viewfield, but it doesn't work.
Was this page helpful?