Theseus 0.3.111: address bar + home search select-on-click
First click of the toolbar's address bar or the home page's search field now selects the current text so the next keystroke replaces it — the long-standing Chrome / Firefox behaviour the two inputs were missing. A second click (while already focused) falls through to native cursor placement, so inline editing still works.
This commit is contained in:
parent
a920737c3c
commit
5829d43482
3 changed files with 22 additions and 2 deletions
13
chrome.html
13
chrome.html
|
|
@ -660,7 +660,18 @@
|
|||
let pickerHasCursor = false;
|
||||
const debouncedSuggest = () => { clearTimeout(suggestTimer); suggestTimer = setTimeout(askSuggest, 80); };
|
||||
$("url").addEventListener("input", () => { pickerHasCursor = false; debouncedSuggest(); });
|
||||
$("url").addEventListener("focus", debouncedSuggest);
|
||||
// Select-all on first focus so a click lands with the current URL ready to
|
||||
// replace, like Chrome / Firefox. A second click (already-focused input)
|
||||
// falls through to the native cursor placement, so editing still works.
|
||||
let urlNeedsSelect = false;
|
||||
$("url").addEventListener("mousedown", (e) => { urlNeedsSelect = (document.activeElement !== e.target); });
|
||||
$("url").addEventListener("mouseup", (e) => { if (urlNeedsSelect) { e.preventDefault(); e.target.select(); urlNeedsSelect = false; } });
|
||||
$("url").addEventListener("focus", (e) => {
|
||||
// Keyboard focus (Tab, address-bar shortcut) — select all. For mouse
|
||||
// focus the mouseup handler above does it; skip to avoid double-fire.
|
||||
if (!urlNeedsSelect) e.target.select();
|
||||
debouncedSuggest();
|
||||
});
|
||||
$("url").addEventListener("blur", () => {
|
||||
// Delay: gives a click on the picker time to register before we close.
|
||||
setTimeout(() => { T.closeAddressPicker(); pickerOpen = false; pickerHasCursor = false; }, 160);
|
||||
|
|
|
|||
|
|
@ -894,6 +894,15 @@
|
|||
};
|
||||
|
||||
// Search form (slot-add button is rendered inside slotsList per render())
|
||||
// Select-all on first click of the search field so a click lands with any
|
||||
// existing query ready to replace. Second click (already-focused) falls
|
||||
// through to native cursor placement.
|
||||
(() => {
|
||||
const q = $("q"); let needSelect = false;
|
||||
q.addEventListener("mousedown", (e) => { needSelect = (document.activeElement !== e.target); });
|
||||
q.addEventListener("mouseup", (e) => { if (needSelect) { e.preventDefault(); e.target.select(); needSelect = false; } });
|
||||
q.addEventListener("focus", (e) => { if (!needSelect) e.target.select(); });
|
||||
})();
|
||||
$("searchForm").addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const q = $("q").value.trim(); if (!q) return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "theseus-navigator",
|
||||
"version": "0.3.110",
|
||||
"version": "0.3.111",
|
||||
"license": "MPL-2.0",
|
||||
"description": "Theseus Navigator — a browser that follows the thread. By Silent Mode, a Deviant project.",
|
||||
"author": "Silent Mode",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue