WJaunita45604 on X: 输入框里面的提示的字显示不全. Sincea44da380b(v0.1.4044) the Add sheet's search hint has been "Find a vendor, or paste a URL and key…" (查找供应商,或粘贴地址和密钥…), in a box 160px wide, so it was cut off in every language. wholeHint (addfloat.js, which the sheet already imports) measures the hint in the box's own font and sets --hint-w, which the CSS now sizes the box by: in the sheet's row and when the tools float into the title bar. Where even that has no room it shows the shorter "Find a provider" (already in every language) instead. At 760px and narrower the box keeps room for that short hint (--hint-s), and Import… wraps to the next line rather than cut it; Custom provider stays on the search's line (add-sheet-custom). Nothing changes in the observer's own turn, the hint included: the next frame measures, sizes the box and then picks, as WebKit calls a change while sizes are being told a loop. The core grows 84 bytes, the import that calls wholeHint, within its budget's room. provider-env-paste asked for the long hint at 440px too. It now waits for the box to be sized and takes either hint below 900px. New add-sheet-hint.test.cjs: every language, both engines, at 1300, 1024, 900, 420 and 360px. It checks the hint's drawn width against the room in the row, floated in the title bar, and after narrowing and widening the window, and asks for the long hint at 1300 and 900px. Run (on mote, Playwright 1.62.0, chromium + webkit): - add-sheet-hint, add-sheet-float, add-sheet, add-sheet-custom, provider-env-paste: 140 of 140 (the add-sheet runs with the #6216 fix). - Broken by hand: the test on origin/main005178104(no wholeHint, its wait for --hint-w swapped for 300ms) is 26 of 26 red, e.g. "the hint fits: 222.125 > 140". - An earlier version that put the search on a line of its own at 520px and narrower broke add-sheet-custom's "on the search's line" at 420px. That is why Import… wraps instead. On mote, both engines: at base077421733, go test -tags nogui ./internal/gui ok and add-sheet*, provider-env-paste, plugin*.test.cjs, old-webkit, i18n-keys and i18n-en-no-cjk green but the reds below and the two the scroll buttons' commit fixes. Rebased on origin/main6e03b746bwith that commit: TestCoreScriptBudget ok with no raise; add-sheet*, provider-env-paste, plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt, the eight plugin files red before, old-webkit, i18n-keys and the scroll files that commit names: green but the reds below. Reds that fail the same on origin/main6e03b746b, run alone there: old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved (#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938), plugin-page-foreign-error (#6117), plugin-option-placement (#6559), rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de 375 (#5869). The whole GUI suite was not run: mote's and mica's loads were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12). Rebased on origin/main1730c75b9, the pushed head (mote): go test -tags nogui ./internal/gui ok; add-sheet*, provider-env-paste, plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt, i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.a82bae2bd, landed on top since, changes the routing plugin, the gateway and i18n.js keys of its own, none of these files; the core measure at the pushed head is 1,267,635 of 1,268,961.
55 lines
3.0 KiB
JavaScript
55 lines
3.0 KiB
JavaScript
// addToolsFloat: the add sheet's tools (search, Custom provider, Import…)
|
|
// scrolled out of sight show in the title bar's empty right, as Library's,
|
|
// Plugins' and Settings' tools do beside the sidebar (app.css
|
|
// .add-tools.afloat); scrolled back they are in their row again. The group
|
|
// itself is pinned, never a copy, so there is one search, its words and
|
|
// focus kept. A narrow window has no room in its bar: the sheet's head is
|
|
// held at the top of the page while the sheet is under it, as Settings'
|
|
// is (app.css). Each change fades in; a fade only, so reduced motion keeps it.
|
|
// app.js renderAdd imports this as the sheet first opens.
|
|
window.addToolsFloat = function (drawn) {
|
|
const v = $("#view-providers"), g = v.querySelector("#addSheet:not([hidden]) .add-tools");
|
|
if (!g) return;
|
|
const head = g.parentElement, sheet = head.parentElement, top = v.getBoundingClientRect().top;
|
|
const side = document.body.classList.contains("side-nav");
|
|
const h = head.getBoundingClientRect();
|
|
const up = side && !v.hidden && h.bottom <= top + 2;
|
|
head.classList.toggle("stuck", !side && h.top - sheet.getBoundingClientRect().top > 6.5);
|
|
if (up === g.classList.contains("afloat")) return;
|
|
g.classList.toggle("afloat", up);
|
|
self.sideTools?.();
|
|
if (!drawn) g.animate([{ opacity: 0 }, { opacity: 1 }], { duration: up ? 180 : 140, easing: "cubic-bezier(.23, 1, .32, 1)" });
|
|
};
|
|
$("#view-providers").addEventListener("scroll", () => addToolsFloat(), { passive: true });
|
|
addEventListener("resize", () => addToolsFloat());
|
|
|
|
// wholeHint: the add sheet's search never cuts its hint off (WJaunita45604
|
|
// on X: 输入框里面的提示的字显示不全); app.js calls it as the sheet draws
|
|
// the search. The box is as wide as its hint (--hint-w, which app.css
|
|
// sizes it by), and where even that has no room, as in a narrow title
|
|
// bar, it gives the shorter hint instead.
|
|
window.wholeHint = function (q, short) {
|
|
const long = q.placeholder;
|
|
// the box's width says nothing until it is sized by its hint
|
|
const pick = (w) => { if (q.style.getPropertyValue("--hint-w")) q.placeholder = q.offsetWidth >= w ? long : short; };
|
|
// nothing changes in the observer's own turn, a placeholder included:
|
|
// WebKit counts any change there as a loop. The next frame measures,
|
|
// sizes the box and picks; --hint-s keeps the short hint room on a
|
|
// phone-wide row
|
|
let due = 0;
|
|
const fit = new ResizeObserver(() => {
|
|
if (!q.isConnected) return fit.disconnect();
|
|
due ||= requestAnimationFrame(() => {
|
|
due = 0;
|
|
const cs = getComputedStyle(q), c = (window.wholeHint.c ||= document.createElement("canvas").getContext("2d"));
|
|
c.font = `${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
|
|
const wide = (s) => Math.ceil(c.measureText(s).width + parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight) + parseFloat(cs.borderLeftWidth) * 2) + 2;
|
|
const w = wide(long);
|
|
q.style.setProperty("--hint-w", w + "px");
|
|
q.style.setProperty("--hint-s", wide(short) + "px");
|
|
pick(w);
|
|
});
|
|
});
|
|
fit.observe(q);
|
|
};
|