Skip to content

Commit

Permalink
disable refocus for outside clicking
Browse files Browse the repository at this point in the history
  • Loading branch information
joduplessis committed Jun 13, 2024
1 parent b46a4dd commit 9f9a157
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/core/src/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,20 @@ export const Select = (props: SelectProps) => {
setText('')
}

const dismiss = () => {
const dismiss = (refocus = true) => {
if (!isStatic) {
hide()
// we simply want to focus the element again
// and not show the list
dontShowListPopup.current = true
if (tagInput) {
focusElement(tagInputFieldRef.current)
} else {
focusElementById(popupId)
if (refocus) {
dontShowListPopup.current = true
if (tagInput) {
focusElement(tagInputFieldRef.current)
} else {
focusElementById(popupId)
}
dontShowListPopup.current = false
}
dontShowListPopup.current = false
}
clear()
}
Expand All @@ -203,7 +205,7 @@ export const Select = (props: SelectProps) => {
const handleClickOutside = (e) => {
if (containerRef.current) {
if (!containerRef.current?.contains(e.target)) {
if (visible) dismiss()
if (visible) dismiss(false)
}
}
}
Expand Down

0 comments on commit 9f9a157

Please sign in to comment.