Keep Bestellungen search focus

This commit is contained in:
2026-06-16 20:13:19 +02:00
parent 0ea233f5ee
commit 557f1793eb
+14 -1
View File
@@ -629,8 +629,20 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $best
echo " table = getTable();"; echo " table = getTable();";
echo " return !!table;"; echo " return !!table;";
echo " };"; echo " };";
echo " const focusSearchInput = () => {";
echo " const input = getSearchInput();";
echo " if (!input) { return; }";
echo " input.focus({ preventScroll: true });";
echo " const end = input.value.length;";
echo " try {";
echo " input.setSelectionRange(end, end);";
echo " } catch (error) {";
echo " void error;";
echo " }";
echo " };";
echo " const loadFragment = async (params) => {"; echo " const loadFragment = async (params) => {";
echo " if (searchTimer) { window.clearTimeout(searchTimer); searchTimer = null; }"; echo " if (searchTimer) { window.clearTimeout(searchTimer); searchTimer = null; }";
echo " const wasSearchFocused = getSearchInput() ? document.activeElement === getSearchInput() : false;";
echo " const url = buildFragmentUrl(params);"; echo " const url = buildFragmentUrl(params);";
echo " const response = await fetch(url.toString(), { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } });"; echo " const response = await fetch(url.toString(), { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } });";
echo " const html = await response.text();"; echo " const html = await response.text();";
@@ -639,6 +651,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $best
echo " const historyUrl = buildUrl(params);"; echo " const historyUrl = buildUrl(params);";
echo " window.history.replaceState({}, '', historyUrl);"; echo " window.history.replaceState({}, '', historyUrl);";
echo " bindTable();"; echo " bindTable();";
echo " if (wasSearchFocused) { focusSearchInput(); }";
echo " }"; echo " }";
echo " };"; echo " };";
echo " const bindTable = () => {"; echo " const bindTable = () => {";
@@ -658,7 +671,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $best
echo " bestellungen_dir: getSortDirection(),"; echo " bestellungen_dir: getSortDirection(),";
echo " bestellungen_limit: getPageSize(),"; echo " bestellungen_limit: getPageSize(),";
echo " });"; echo " });";
echo " }, 250);"; echo " }, 500);";
echo " });"; echo " });";
echo " }"; echo " }";
echo " if (clearButton && clearButton.dataset.bestellungenBound !== 'true') {"; echo " if (clearButton && clearButton.dataset.bestellungenBound !== 'true') {";