leap: hide pointer while navigating by keyboard

fixes urbit/landscape#598
This commit is contained in:
James Acklin 2021-04-12 15:12:03 -04:00
parent 1f70fdbf2d
commit 92c39dc526
2 changed files with 9 additions and 3 deletions

View File

@ -39,7 +39,7 @@ const SEARCHED_CATEGORIES = [
'other',
'groups',
'subscriptions',
'apps',
'apps'
];
const settingsSel = (s: SettingsState) => s.leap;
@ -56,6 +56,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
const notifications = useHarkState(state => state.notifications);
const invites = useInviteState(state => state.invites);
const tiles = useLaunchState(state => state.tiles);
const [leapCursor, setLeapCursor] = useState('pointer');
const contacts = useMemo(() => {
const maybeShip = `~${deSig(query)}`;
@ -113,7 +114,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
if (category === 'other') {
return [
'other',
index.get('other').filter(({ app }) => app !== 'tutorial'),
index.get('other').filter(({ app }) => app !== 'tutorial')
];
}
return [category, []];
@ -211,6 +212,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
}, [selected, results]);
const setSelection = (app, link) => {
setLeapCursor('pointer');
setSelected([app, link]);
};
@ -228,11 +230,13 @@ export function Omnibox(props: OmniboxProps): ReactElement {
if (evt.key === 'ArrowUp' || (evt.shiftKey && evt.key === 'Tab')) {
evt.preventDefault();
setPreviousSelected();
setLeapCursor('none');
return;
}
if (evt.key === 'ArrowDown' || evt.key === 'Tab') {
evt.preventDefault();
setNextSelected();
setLeapCursor('none');
return;
}
if (evt.key === 'Enter') {
@ -325,6 +329,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
text={result.title}
subtext={result.host}
link={result.link}
cursor={leapCursor}
navigate={() => navigate(result.app, result.link)}
setSelection={() => setSelection(result.app, result.link)}
selected={sel}

View File

@ -173,6 +173,7 @@ export class OmniboxResult extends Component {
text,
subtext,
link,
cursor,
navigate,
selected,
invites,
@ -198,7 +199,7 @@ export class OmniboxResult extends Component {
<Row
py='2'
px='2'
cursor='pointer'
cursor={cursor}
onMouseMove={() => setSelection()}
onMouseLeave={() => this.setHover(false)}
backgroundColor={