Skip to content

Commit

Permalink
fix(pro:search): clickside should exclude overlay container (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 authored Sep 15, 2022
1 parent 121b612 commit bd2d1b9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/pro/search/src/ProSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ export default defineComponent({
const activeSegmentContext = useActiveSegment(props, searchItems, searchStateContext.tempSearchStateAvailable)
const commonOverlayProps = useCommonOverlayProps(mergedPrefixCls, props, config)

const overlayContainer = computed(() => {
const target = commonOverlayProps.value.target
return isFunction(target) ? target() : target
})

const { initSearchStates, updateSearchState, clearSearchState, tempSearchState } = searchStateContext
const { activeSegment, setInactive, setTempActive } = activeSegmentContext

Expand Down Expand Up @@ -101,18 +96,23 @@ export default defineComponent({
evt.preventDefault()
setTempSegmentActive()
}

const getContainerEl = () => {
const containerProp = commonOverlayProps.value.container
const container = isFunction(containerProp) ? containerProp() : containerProp

return isString(container) ? document.querySelector(container) : container
}
const handleClickOutside = (evt: MouseEvent) => {
if (!activeSegment.value) {
previousActiveSegmentName = undefined
return
}

const paths = evt.composedPath()
const target = overlayContainer.value
const container = getContainerEl()

if (
paths.some(path => (isString(target) ? (path as HTMLElement).classList?.contains(target) : path === target))
) {
if (container && paths.includes(container)) {
return
}

Expand Down

0 comments on commit bd2d1b9

Please sign in to comment.