From 29bd50ef60e37d5b8d799cef7640c439023b4fa8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 6 Mar 2024 10:31:47 -0800 Subject: [PATCH] Fix for compatibility issue with quick edit extension Signed-off-by: Matt Friedman --- event/listener.php | 2 +- tests/event/listener_test.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/event/listener.php b/event/listener.php index e4f3e47..3c40b5b 100644 --- a/event/listener.php +++ b/event/listener.php @@ -162,7 +162,7 @@ protected function get_selected_prefix($event) $prefix_id = $this->request->variable('topic_prefix', 0); // If we are in preview mode, send back the prefix from the form - if (!empty($event['preview'])) + if (!empty($event['preview']) && $event['mode'] !== 'edit') { return $prefix_id; } diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 4486e63..2bbea07 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -214,6 +214,18 @@ public function data_add_to_posting_form() 'SELECTED_PREFIX' => '[foo]', ), ), + array( // test adding selected prefix when previewing a new topic + $prefix_data, + array( + 'mode' => 'post', + 'preview' => true, + ), + 1, + array( + 'PREFIXES' => $prefix_data, + 'SELECTED_PREFIX' => '[foo]', + ), + ), array( // test adding null selected prefix when posting new topic with bad data $prefix_data, array('mode' => 'post'), @@ -223,6 +235,18 @@ public function data_add_to_posting_form() 'SELECTED_PREFIX' => '', ), ), + array( // test adding null selected prefix when previewing new topic with bad data + $prefix_data, + array( + 'mode' => 'post', + 'preview' => true, + ), + 2, + array( + 'PREFIXES' => $prefix_data, + 'SELECTED_PREFIX' => '', + ), + ), array( // test post preview mode shows the expected prefix when no prefix is selected $prefix_data, array(