mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
renamed onKeyUp --> onKeyDown
This commit is contained in:
parent
ef6c5b9068
commit
9778c9ba9a
2 changed files with 5 additions and 5 deletions
|
@ -44,6 +44,7 @@ const TagAutocompleteUnconnected: FC<Props> = ({
|
|||
const onKeyDown = useCallback(
|
||||
event => {
|
||||
const all = [...categories, ...tags];
|
||||
|
||||
switch (event.key) {
|
||||
case 'ArrowDown':
|
||||
event.preventDefault();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { ChangeEvent, FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
||||
import React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
||||
import { TagAutocomplete } from '~/components/tags/TagAutocomplete';
|
||||
import { TagWrapper } from '~/components/tags/TagWrapper';
|
||||
import styles from './styles.module.scss';
|
||||
|
@ -48,8 +48,8 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
|||
[setInput]
|
||||
);
|
||||
|
||||
const onKeyUp = useCallback(
|
||||
({ key }: KeyboardEvent) => {
|
||||
const onKeyDown = useCallback(
|
||||
({ key }) => {
|
||||
if (key === 'Escape' && ref.current) {
|
||||
setInput('');
|
||||
ref.current.blur();
|
||||
|
@ -105,7 +105,6 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
|||
|
||||
useEffect(() => {
|
||||
document.addEventListener('click', onBlur);
|
||||
|
||||
return () => document.removeEventListener('click', onBlur);
|
||||
}, [onBlur]);
|
||||
|
||||
|
@ -119,7 +118,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
|||
placeholder={placeholder}
|
||||
maxLength={24}
|
||||
onChange={onInput}
|
||||
onKeyDown={onKeyUp}
|
||||
onKeyDown={onKeyDown}
|
||||
onFocus={onFocus}
|
||||
ref={ref}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue