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(
|
const onKeyDown = useCallback(
|
||||||
event => {
|
event => {
|
||||||
const all = [...categories, ...tags];
|
const all = [...categories, ...tags];
|
||||||
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case 'ArrowDown':
|
case 'ArrowDown':
|
||||||
event.preventDefault();
|
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 { TagAutocomplete } from '~/components/tags/TagAutocomplete';
|
||||||
import { TagWrapper } from '~/components/tags/TagWrapper';
|
import { TagWrapper } from '~/components/tags/TagWrapper';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
@ -48,8 +48,8 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
[setInput]
|
[setInput]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onKeyUp = useCallback(
|
const onKeyDown = useCallback(
|
||||||
({ key }: KeyboardEvent) => {
|
({ key }) => {
|
||||||
if (key === 'Escape' && ref.current) {
|
if (key === 'Escape' && ref.current) {
|
||||||
setInput('');
|
setInput('');
|
||||||
ref.current.blur();
|
ref.current.blur();
|
||||||
|
@ -105,7 +105,6 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.addEventListener('click', onBlur);
|
document.addEventListener('click', onBlur);
|
||||||
|
|
||||||
return () => document.removeEventListener('click', onBlur);
|
return () => document.removeEventListener('click', onBlur);
|
||||||
}, [onBlur]);
|
}, [onBlur]);
|
||||||
|
|
||||||
|
@ -119,7 +118,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
maxLength={24}
|
maxLength={24}
|
||||||
onChange={onInput}
|
onChange={onInput}
|
||||||
onKeyDown={onKeyUp}
|
onKeyDown={onKeyDown}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue