kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
"Gambiarra" to search
rodzic
cb2cc325d1
commit
754fa6e761
|
@ -2,7 +2,7 @@ import searchIcon from '@tabler/icons/outline/search.svg';
|
||||||
import xIcon from '@tabler/icons/outline/x.svg';
|
import xIcon from '@tabler/icons/outline/x.svg';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { debounce } from 'es-toolkit';
|
import { debounce } from 'es-toolkit';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ const Search = (props: ISearch) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const [inputValue, setInputValue] = useState('');
|
||||||
|
|
||||||
const value = useAppSelector((state) => state.search.value);
|
const value = useAppSelector((state) => state.search.value);
|
||||||
const submitted = useAppSelector((state) => state.search.submitted);
|
const submitted = useAppSelector((state) => state.search.submitted);
|
||||||
|
@ -67,6 +68,7 @@ const Search = (props: ISearch) => {
|
||||||
const { value } = event.target;
|
const { value } = event.target;
|
||||||
|
|
||||||
dispatch(changeSearch(value));
|
dispatch(changeSearch(value));
|
||||||
|
setInputValue(value);
|
||||||
|
|
||||||
if (autoSubmit) {
|
if (autoSubmit) {
|
||||||
debouncedSubmit();
|
debouncedSubmit();
|
||||||
|
@ -124,7 +126,7 @@ const Search = (props: ISearch) => {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
id: 'search',
|
id: 'search',
|
||||||
placeholder: intl.formatMessage(messages.placeholder),
|
placeholder: intl.formatMessage(messages.placeholder),
|
||||||
value,
|
inputValue,
|
||||||
onChange: handleChange,
|
onChange: handleChange,
|
||||||
onKeyDown: handleKeyDown,
|
onKeyDown: handleKeyDown,
|
||||||
onFocus: handleFocus,
|
onFocus: handleFocus,
|
||||||
|
|
Ładowanie…
Reference in New Issue