Skip to content

Commit 5a66a2a

Browse files
tkirda-bisonclaude
andcommitted
docs(pages): tighten demo cleanup
Follow-up to 1440849 — fixes flagged by code review: - Drop unused `--paper-4` CSS variable. - Remove empty `.demo__readout:not(:empty):not(:has(*))` ruleset (the comment was its only content). - Cache `$('#autocomplete-ajax-x')` as `$ghost` in demo.js so the per- keystroke `onHint` callback doesn't re-query the DOM. - Drop duplicate `aria-label="Suggestions render here"` on `#suggestions-container` — the visible `<span>` text already conveys it, so the label was causing duplicate screen-reader announcements. - Replace sub-pixel `1.5px` border / `0.5px` padding on the match- highlight `<strong>` with whole-pixel values (browsers were rounding the sub-pixels inconsistently across rows). - Drop the redundant `color` transition on `.autocomplete-suggestion` (selected and default both resolve to `--ink`, so it was a no-op). - Derive `.ghost-stack` height from `1lh + padding + border` rather than a hardcoded `3.5rem`, with `min-height` as a fallback — keeps the ghost field in sync with the input's actual line metrics including on narrow viewports where font-size drops. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1440849 commit 5a66a2a

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

docs/content/styles.css

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
--paper: #f4eee2;
1010
--paper-2: #faf6ec;
1111
--paper-3: #ebe3d0;
12-
--paper-4: #e0d5bb;
1312
--ink: #1c1a16;
1413
--ink-2: #524c43;
1514
--ink-3: #8a8275;
@@ -320,7 +319,6 @@ p, h1, h2, h3 { margin: 0; }
320319
line-height: 1.45;
321320
transition: border-color 0.2s ease, color 0.2s ease;
322321
}
323-
.demo__readout:not(:empty):not(:has(*)) { /* default empty state */ }
324322
.demo__readout.has-selection {
325323
border-left-color: var(--accent);
326324
color: var(--ink);
@@ -361,7 +359,8 @@ p, h1, h2, h3 { margin: 0; }
361359
/* ghost (#01) */
362360
.ghost-stack {
363361
position: relative;
364-
height: 3.5rem;
362+
min-height: 3.5rem;
363+
height: calc(1lh + 1.4em + 2px); /* font line + 2× 0.7em padding + 1px border */
365364
}
366365
.ghost-stack__main,
367366
.ghost-stack__ghost {
@@ -455,7 +454,7 @@ p, h1, h2, h3 { margin: 0; }
455454
white-space: nowrap;
456455
overflow: hidden;
457456
text-overflow: ellipsis;
458-
transition: background 0.08s ease, color 0.08s ease;
457+
transition: background 0.08s ease;
459458
line-height: 1.35;
460459
}
461460
.autocomplete-no-suggestion {
@@ -469,11 +468,11 @@ p, h1, h2, h3 { margin: 0; }
469468
color: var(--ink);
470469
}
471470
.autocomplete-suggestions strong {
471+
/* match highlight rendered as an editor's underline, not bold-only */
472472
font-weight: 600;
473473
color: var(--accent-2);
474-
border-bottom: 1.5px solid var(--accent);
475-
padding-bottom: 0.5px;
476-
/* a printer's editorial underline, not a bold-only emphasis */
474+
border-bottom: 1px solid var(--accent);
475+
padding-bottom: 1px;
477476
}
478477
.autocomplete-group {
479478
padding: 0.6em 0.95em 0.5em;

docs/index.htm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ <h2 class="demo__title">Custom suggestion container</h2>
152152
<input class="demo__input demo__input--narrow" type="text"
153153
id="autocomplete-custom-append" autocomplete="off"
154154
placeholder="country">
155-
<div id="suggestions-container" class="inline-stack__sink"
156-
aria-label="Suggestions render here">
155+
<div id="suggestions-container" class="inline-stack__sink">
157156
<span class="inline-stack__hint">Suggestions render here &rarr;</span>
158157
</div>
159158
</div>

docs/scripts/demo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ $(function () {
3838
// 01 — Ajax lookup with ghost completion
3939
// -----------------------------------------------------------------
4040
var $selectionAjax = $('#selection-ajax');
41+
var $ghost = $('#autocomplete-ajax-x');
4142

4243
$('#autocomplete-ajax').devbridgeAutocomplete({
4344
serviceUrl: '/api/countries',
@@ -50,7 +51,7 @@ $(function () {
5051
);
5152
},
5253
onHint: function (hint) {
53-
$('#autocomplete-ajax-x').val(hint);
54+
$ghost.val(hint);
5455
},
5556
onInvalidateSelection: function () {
5657
$selectionAjax.removeClass('has-selection').text('No selection.');

0 commit comments

Comments
 (0)