From b0a4f4f223370cab8d3e6f0eb278d784c23e97ce Mon Sep 17 00:00:00 2001 From: abrahammordev Date: Tue, 7 Apr 2026 12:27:18 +0200 Subject: [PATCH 1/2] 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 From 541b7d300d8b1144bc1f1aa4c51b68906f1503a8 Mon Sep 17 00:00:00 2001 From: abrahammordev Date: Thu, 23 Jul 2026 11:44:43 +0200 Subject: [PATCH 2/2] fix: Use handleApplyAndToggle to manage filter --- .../Mail/classes/Folder/MailFilterUI.php | 21 +------------------ .../Mail/classes/class.ilMailFolderGUI.php | 8 ------- .../UI_/classes/class.ilUIFilterService.php | 18 ++++++++++++++++ 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/components/ILIAS/Mail/classes/Folder/MailFilterUI.php b/components/ILIAS/Mail/classes/Folder/MailFilterUI.php index a1534fa9058e..ddc3e82811dd 100644 --- a/components/ILIAS/Mail/classes/Folder/MailFilterUI.php +++ b/components/ILIAS/Mail/classes/Folder/MailFilterUI.php @@ -41,8 +41,7 @@ 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 bool $focus_first_filter_input_after_apply = false + private readonly DateTimeZone $user_time_zone ) { $inputs = []; if ($this->folder->hasIncomingMails()) { @@ -82,24 +81,6 @@ 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 diff --git a/components/ILIAS/UI_/classes/class.ilUIFilterService.php b/components/ILIAS/UI_/classes/class.ilUIFilterService.php index ee8f92dbfed4..2cc89316bc8f 100755 --- a/components/ILIAS/UI_/classes/class.ilUIFilterService.php +++ b/components/ILIAS/UI_/classes/class.ilUIFilterService.php @@ -208,6 +208,24 @@ protected function handleApplyAndToggle(string $filter_id, Filter\Standard $filt ))) { $filter = $this->request->getFilterWithRequest($filter); + if ($this->request->getFilterCmd() === self::CMD_APPLY) { + $filter = $filter->withAdditionalOnLoadCode( + static fn(string $id): string => <<request->getFilterCmd() == self::CMD_TOGGLE_ON) { $result = $filter->getData();