Skip to content

Commit 3927d74

Browse files
committed
feat: simplify types
1 parent a420ba8 commit 3927d74

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-autocomplete-dropdown-playground",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"private": true,
55
"license": "MIT",
66
"author": "Alexandr Kozhevnikov <[email protected]>",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-autocomplete-dropdown",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"description": "Dropdown Item picker with search and autocomplete (typeahead) functionality for react native",
55
"keywords": [
66
"react-native",

src/index.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const AutocompleteDropdown = memo<
128128
setDirection((screenHeight - kbHeight) / 2 > positionY ? 'down' : 'up')
129129
resolve()
130130
},
131-
waitForKeyboard ? Platform.select({ ios: 600, android: 150, default: 1 }) : 1, // wait for keyboard to show
131+
waitForKeyboard ? Platform.select({ ios: 600, android: 250, default: 1 }) : 1, // wait for keyboard to show
132132
)
133133
})
134134
},
@@ -156,20 +156,17 @@ export const AutocompleteDropdown = memo<
156156
inputRef.current?.blur()
157157
}, [])
158158

159-
const open = useCallback(
160-
async ({ focused } = { focused: false }) => {
161-
if (directionProp) {
162-
setDirection(directionProp)
163-
} else {
164-
await calculateDirection({ waitForKeyboard: focused })
165-
}
159+
const open = useCallback(async () => {
160+
if (directionProp) {
161+
setDirection(directionProp)
162+
} else {
163+
await calculateDirection({ waitForKeyboard: !!inputRef.current?.isFocused() })
164+
}
166165

167-
setTimeout(() => {
168-
setIsOpened(true)
169-
}, 0)
170-
},
171-
[calculateDirection, directionProp, setDirection],
172-
)
166+
setTimeout(() => {
167+
setIsOpened(true)
168+
}, 0)
169+
}, [calculateDirection, directionProp, setDirection])
173170

174171
const toggle = useCallback(() => {
175172
isOpened ? close() : open()
@@ -396,7 +393,7 @@ export const AutocompleteDropdown = memo<
396393
if (typeof onFocusProp === 'function') {
397394
onFocusProp(e)
398395
}
399-
open({ focused: true })
396+
open()
400397
},
401398
[clearOnFocus, onFocusProp, open],
402399
)

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface IAutocompleteDropdownRef {
1111
clear: () => void
1212
close: () => void
1313
blur: () => void
14-
open: (params?: { focused: boolean }) => Promise<void>
14+
open: () => Promise<void>
1515
setInputText: (text: string) => void
1616
toggle: () => void
1717
setItem: (item: AutocompleteDropdownItem) => void

0 commit comments

Comments
 (0)