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