From b0a4f4f223370cab8d3e6f0eb278d784c23e97ce Mon Sep 17 00:00:00 2001 From: abrahammordev Date: Tue, 7 Apr 2026 12:27:18 +0200 Subject: [PATCH] fix: Set focus to form when applying filters --- .../Mail/classes/Folder/MailFilterUI.php | 21 ++++++++++++++++++- .../Mail/classes/class.ilMailFolderGUI.php | 8 +++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/Mail/classes/Folder/MailFilterUI.php b/components/ILIAS/Mail/classes/Folder/MailFilterUI.php index ddc3e82811dd..a1534fa9058e 100644 --- a/components/ILIAS/Mail/classes/Folder/MailFilterUI.php +++ b/components/ILIAS/Mail/classes/Folder/MailFilterUI.php @@ -41,7 +41,8 @@ public function __construct( private readonly Factory $ui_factory, private readonly ilUIFilterService $filter_service, private readonly ilLanguage $lng, - private readonly DateTimeZone $user_time_zone + private readonly DateTimeZone $user_time_zone, + private readonly bool $focus_first_filter_input_after_apply = false ) { $inputs = []; if ($this->folder->hasIncomingMails()) { @@ -81,6 +82,24 @@ public function __construct( false, false ); + + if ($this->focus_first_filter_input_after_apply) { + $this->filter = $this->filter->withAdditionalOnLoadCode( + static fn(string $id): string => <<ui_service->filter(), $this->lng, new DateTimeZone($this->user->getTimeZone()), + $this->shouldFocusFirstFilterInputAfterApply(), ); } + protected function shouldFocusFirstFilterInputAfterApply(): bool + { + $query_params = $this->http->request()->getQueryParams(); + + return ($query_params[ilUIFilterRequestAdapter::CMD_PARAMETER] ?? '') === ilUIFilterService::CMD_APPLY; + } + /** * Searcher for mails in the folder, initialized with the current filter values * needed for table display and actions for the whole table