Skip to content

Commit 48d9e6b

Browse files
committed
Clean up internal collapse and expand functions
1 parent 6555f2c commit 48d9e6b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/hooks/useManager.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function useManager({
9292
if (value) {
9393
if (allowNew) {
9494
opts.push({
95-
disabled: typeof onValidate === 'function' ? !onValidate(value) : false,
95+
disabled: onValidate ? !onValidate(value) : false,
9696
label: newOptionText,
9797
value: NewOptionValue,
9898
})
@@ -129,23 +129,19 @@ export function useManager({
129129
}
130130

131131
const api: ManagerAPI = {
132-
listBoxCollapse(newValue?: string) {
132+
listBoxCollapse(value?: string) {
133133
if (!isExpanded) return
134134

135-
const collapse = onShouldCollapse ? onShouldCollapse(newValue ?? state.value) : true
136-
137-
if (collapse) {
135+
if (onShouldCollapse ? onShouldCollapse(value ?? state.value) : true) {
138136
setIsExpanded(false)
139137
setLastActiveOption(null)
140138
onCollapse?.()
141139
}
142140
},
143-
listBoxExpand(newValue?: string) {
141+
listBoxExpand(value?: string) {
144142
if (isExpanded) return
145143

146-
const expand = onShouldExpand ? onShouldExpand(newValue ?? state.value) : true
147-
148-
if (expand) {
144+
if (onShouldExpand ? onShouldExpand(value ?? state.value) : true) {
149145
setIsExpanded(true)
150146
setLastActiveOption(options[activeIndex])
151147
onExpand?.()

0 commit comments

Comments
 (0)