Skip to content

Commit 7250383

Browse files
committed
ux improvements for demo
1 parent ac8b4c3 commit 7250383

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

special-pages/pages/history/app/components/Header.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@
5454
border: 1px solid var(--history-surface-border-color);
5555
padding-left: 9px;
5656
padding-right: 9px;
57+
background: inherit;
58+
color: inherit;
59+
&:focus {
60+
outline: none;
61+
}
5762
}

special-pages/pages/history/app/components/SearchForm.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styles from './Header.module.css';
22
import { createContext, h } from 'preact';
3-
import { useSettings, useTypedTranslation } from '../types.js';
3+
import { usePlatformName, useSettings, useTypedTranslation } from '../types.js';
44
import { signal, useComputed, useSignal, useSignalEffect } from '@preact/signals';
55
import { useContext } from 'preact/hooks';
66
import { toRange } from '../history.service.js';
@@ -54,6 +54,7 @@ export function SearchProvider({ children, query = { term: '' } }) {
5454
const derivedTerm = useComputed(() => searchState.value.term);
5555
const derivedRange = useComputed(() => searchState.value.range);
5656
const settings = useSettings();
57+
const platformName = usePlatformName();
5758
// todo: domain search
5859
// const derivedDomain = useComputed(() => searchState.value.domain);
5960
useSignalEffect(() => {
@@ -113,7 +114,24 @@ export function SearchProvider({ children, query = { term: '' } }) {
113114
}
114115
});
115116

117+
const keydown = (e) => {
118+
const isMacOS = platformName === 'macos';
119+
const isFindShortcutMacOS = isMacOS && e.metaKey && e.key === 'f';
120+
const isFindShortcutWindows = !isMacOS && e.ctrlKey && e.key === 'f';
121+
122+
if (isFindShortcutMacOS || isFindShortcutWindows) {
123+
e.preventDefault();
124+
const searchInput = /** @type {HTMLInputElement|null} */ (document.querySelector(`input[type="search"]`));
125+
if (searchInput) {
126+
searchInput.focus();
127+
}
128+
}
129+
};
130+
131+
document.addEventListener('keydown', keydown);
132+
116133
return () => {
134+
document.removeEventListener('keydown', keydown);
117135
controller.abort();
118136
};
119137
});

0 commit comments

Comments
 (0)