git: 1adfd1e570 - main - ports.cgi: set the autofocus at the end of the search query
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 17 Sep 2026 11:21:53 UTC
The branch main has been updated by wosch:
URL: https://cgit.FreeBSD.org/doc/commit/?id=1adfd1e570e0a4f4d0f3b8286e9beb7203565161
commit 1adfd1e570e0a4f4d0f3b8286e9beb7203565161
Author: Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2026-09-17 11:19:34 +0000
Commit: Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2026-09-17 11:19:34 +0000
ports.cgi: set the autofocus at the end of the search query
Most browsers set the the autofocus at the beginning of the
input field which is not very helpful.
---
website/content/en/cgi/ports.cgi | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/website/content/en/cgi/ports.cgi b/website/content/en/cgi/ports.cgi
index 8b9ad091cd..dc128ecaef 100755
--- a/website/content/en/cgi/ports.cgi
+++ b/website/content/en/cgi/ports.cgi
@@ -602,11 +602,22 @@ sub search_ports {
}
}
+sub input_autofocus_at_end {
+ return <<EOF;
+
+<script>
+const input = document.querySelector('#query');
+input.focus();
+input.setSelectionRange(input.value.length, input.value.length);
+</script>
+EOF
+}
+
sub forms {
print qq{
<form id="ports" method="get" action="$script_name">
-<input name="query" value="$query" type="text" autocapitalize="none" autofocus />
+<input name="query" id="query" value="$query" type="text" autocapitalize="none" autofocus />
<select name="stype">
};
@@ -927,5 +938,6 @@ if ($counter) {
print &footer_links;
}
+print &input_autofocus_at_end;
print qq{<hr noshade="noshade" />\n};
print &html_footer;