Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion components/ILIAS/Mail/classes/Folder/MailFilterUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 => <<<JS
window.setTimeout(function() {
const filterSection = document.getElementById('section_inputs_{$id}');
if (!filterSection) {
return;
}

const firstFocusable = filterSection.querySelector('input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])');
if (firstFocusable instanceof HTMLElement) {
firstFocusable.focus();
}
}, 25);
JS
);
}
}

/**
Expand Down
8 changes: 8 additions & 0 deletions components/ILIAS/Mail/classes/class.ilMailFolderGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,17 @@ protected function getFilterUI(): MailFilterUI
$this->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
Expand Down
Loading