Skip to content

Commit

Permalink
πŸ› fix(fixeditem): can't get active after filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
anubra266 committed Jun 1, 2021
1 parent db030bd commit 2292343
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
7 changes: 3 additions & 4 deletions example/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const App = () => {
<AutoCompleteInput
variant="filled"
placeholder="Search..."
// defaultValue="app"
defaultValue="app"
autoFocus
/>
<AutoCompleteList>
Expand Down Expand Up @@ -63,16 +63,15 @@ const App = () => {
>
Create New
</AutoCompleteFixedItem>
<Flex onClick={() => setOptions(o => [...o, 'new'])}>Create New</Flex>
</AutoCompleteList>
</AutoComplete>
<Button
{/* <Button
zIndex="tooltip"
mt="150px"
onClick={() => setOptions(o => [...o, 'new'])}
>
Add Option
</Button>
</Button> */}
{/* <AutoComplete
rollNavigation
focusInputOnSelect
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
],
"devDependencies": {
"@size-limit/preset-small-lib": "^4.10.2",
"@types/react": "^17.0.8",
"@types/react": "^17.0.5",
"@types/react-dom": "^17.0.5",
"husky": "^6.0.0",
"react": "^17.0.2",
"react": "^0.14.0 || ^15.0.0 || ^16.0.0-0",
"react-dom": "^17.0.2",
"size-limit": "^4.10.2",
"tsdx": "^0.14.1",
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const useOptionsFilter = () => {
const inputValue = input.value;
const options = item.list;
const filteredItems = options.filter(
i => i.value.toLowerCase().indexOf(inputValue.toLowerCase()) > -1
i =>
i.value.toLowerCase().indexOf(inputValue.toLowerCase()) > -1 ||
i.value.trim().length === 0
);

//? Update input state if there's a defaultValue for input
Expand Down
14 changes: 10 additions & 4 deletions src/store/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BoxProps } from '@chakra-ui/react';
import { createContext } from '@chakra-ui/react-utils';
import React, { Dispatch } from 'react';
import React, { Context, Dispatch, Provider } from 'react';
import { AutoComplete } from '../auto-complete-provider';
import { AutoCompleteActions } from './reducers/autocomplete';
import { InputActions } from './reducers/input';
Expand Down Expand Up @@ -49,9 +49,15 @@ type ContextValue = {
dispatch: StoreDispatch;
};

export const [AutoCompleteProvider, useAutoCompleteContext] = createContext<
ContextValue
>({
type ContextReturn = [
Provider<ContextValue>,
() => ContextValue,
Context<ContextValue>
];
export const [
AutoCompleteProvider,
useAutoCompleteContext,
]: ContextReturn = createContext<ContextValue>({
name: 'AutoCompleteContext',
});

Expand Down
13 changes: 7 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@
"@types/scheduler" "*"
csstype "^3.0.2"

"@types/react@^17.0.8":
"@types/react@^17.0.5":
version "17.0.8"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.8.tgz#fe76e3ba0fbb5602704110fd1e3035cf394778e3"
integrity sha512-3sx4c0PbXujrYAKwXxNONXUtRp9C+hE2di0IuxFyf5BELD+B+AXL8G7QrmSKhVwKZDbv0igiAjQAMhXj8Yg3aw==
Expand Down Expand Up @@ -6740,7 +6740,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.7.2:
prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -6865,13 +6865,14 @@ react-is@^16.12.0, react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==
"react@^0.14.0 || ^15.0.0 || ^16.0.0-0":
version "16.14.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"

read-pkg-up@^3.0.0:
version "3.0.0"
Expand Down

0 comments on commit 2292343

Please sign in to comment.