diff --git a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php index 282aaaf..900f8bd 100644 --- a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php +++ b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php @@ -130,8 +130,8 @@ public function mount(int|string $record): void $this->fillEditorial(); // Die gezeigte Fassung wird festgehalten. Sonst wechselte die Anzeige still auf eine andere Fassung, sobald // eine Freigabe oder neue Fassung die Vorgabe „neueste freigegebene“ ändert, während das Textfeld noch den - // Wortlaut der bisherigen enthält. - $this->fassung ??= $this->shownVersion()?->id; + // Wortlaut der bisherigen enthält. Eine fremde oder ungültige Angabe in der Adresse wird dabei ersetzt. + $this->fassung = $this->shownVersion()?->id; $this->syncBodyDraft(); if (in_array($bereich, ['praesentation', 'redaktion'], true) && $this->canEditEditorial()) { diff --git a/tests/Feature/VerwaltungArbeitsplatzTest.php b/tests/Feature/VerwaltungArbeitsplatzTest.php index 27754f0..b46d799 100644 --- a/tests/Feature/VerwaltungArbeitsplatzTest.php +++ b/tests/Feature/VerwaltungArbeitsplatzTest.php @@ -701,6 +701,25 @@ public function test_releasing_another_version_does_not_move_the_shown_text_onto $this->assertSame('Zweiter Wortlaut', $draft->fresh()->body); } + public function test_a_foreign_version_in_the_address_still_pins_the_shown_version(): void + { + $content = app(ContentService::class); + $text = $content->createElement('text', 'text', 'Trainerunterlage'); + $first = $content->publishElementVersion($text, 'Erster Wortlaut'); + $draft = $content->draftElementVersion($text, 'Zweiter Wortlaut'); + $foreign = $content->publishElementVersion($content->createElement('text', 'text', 'Anderes Blatt'), 'Fremd'); + + Livewire::withQueryParams(['fassung' => $foreign->id]) + ->actingAs($this->editor(), 'staff') + ->test(ViewContentElement::class, ['record' => $text->getKey()]) + ->assertSet('fassung', $first->id) + ->assertSet('bodyDraft', 'Erster Wortlaut') + ->callAction('releaseVersion', [], ['version' => $draft->id]) + ->assertSet('fassung', $first->id) + ->assertSet('bodyDraft', 'Erster Wortlaut') + ->assertDontSee('Text der Fassung nicht gespeichert'); + } + public function test_a_new_version_from_the_dialog_is_shown_with_its_own_text(): void { $content = app(ContentService::class);