Skip to content

Commit 6025cd8

Browse files
committed
tweaks
1 parent 803454d commit 6025cd8

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

packages/site-kit/src/lib/actions/focus.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@ export function focusable_children(node: HTMLElement) {
1515
nodes[i].focus();
1616
};
1717

18-
return {
19-
next: (selector?: string) => {
20-
const reordered = [...nodes.slice(index + 1), ...nodes.slice(0, index + 1)];
18+
function traverse(d: number, selector?: string) {
19+
const reordered = [...nodes.slice(index), ...nodes.slice(0, index)];
20+
21+
let i = (reordered.length + d) % reordered.length;
22+
let node;
23+
24+
while ((node = reordered[i])) {
25+
i += d;
2126

22-
for (let i = 0; i < reordered.length; i += 1) {
23-
if (!selector || reordered[i].matches(selector)) {
24-
reordered[i].focus();
25-
return;
26-
}
27+
if (node.matches('details:not([open]) *')) {
28+
continue;
2729
}
28-
},
29-
prev: (selector?: string) => {
30-
const reordered = [...nodes.slice(index + 1), ...nodes.slice(0, index + 1)];
3130

32-
for (let i = reordered.length - 2; i >= 0; i -= 1) {
33-
if (!selector || reordered[i].matches(selector)) {
34-
reordered[i].focus();
35-
return;
36-
}
31+
if (!selector || node.matches(selector)) {
32+
node.focus();
33+
return;
3734
}
38-
},
35+
}
36+
}
37+
38+
return {
39+
next: (selector?: string) => traverse(1, selector),
40+
prev: (selector?: string) => traverse(-1, selector),
3941
update
4042
};
4143
}

packages/site-kit/src/lib/search/SearchBox.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ It appears when the user clicks on the `Search` component or presses the corresp
181181
/>
182182

183183
<button aria-label="Close" onclick={close}>
184-
<Icon name="close" />
184+
<!-- <Icon name="close" /> -->
185+
<kbd>Esc</kbd>
185186
</button>
186187

187188
<span id="search-description" class="visually-hidden">
@@ -305,6 +306,10 @@ It appears when the user clicks on the `Search` component or presses the corresp
305306
opacity: 1;
306307
outline-offset: -3px;
307308
}
309+
310+
kbd {
311+
text-transform: uppercase;
312+
}
308313
}
309314
310315
ul {

packages/site-kit/src/lib/search/SearchResultList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
&::after {
8282
content: '';
8383
position: absolute;
84-
right: 1rem;
84+
right: 1.6rem;
8585
top: calc(50% - 1rem);
8686
width: 2rem;
8787
height: 2rem;

0 commit comments

Comments
 (0)