Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(popselect): 修复 n-popselect 组件的 header插槽里 input无法输入的问题 #5494

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/drawer/src/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,16 @@ export default defineComponent({
if (onMaskClick) onMaskClick(e)
}

function handleOutsideClick (e: MouseEvent): void {
handleMaskClick(e)
// handleMaskClick event runs the risk of being executed multiple times
// so the onClickoutside logic is handled separately
function onClickoutside (e: MouseEvent): void {
const className = (e.target as Element).className
const mask = `${mergedClsPrefixRef.value}-drawer-mask`
const target = className?.split(' ')
// if the element triggered by a click is not a mask layer
if (target && target[0] !== mask) {
doUpdateShow(false)
}
}

const isComposingRef = useIsComposing()
Expand Down Expand Up @@ -315,6 +323,7 @@ export default defineComponent({
mergedBodyStyle: mergedBodyStyleRef,
handleOutsideClick,
handleMaskClick,
onClickoutside,
handleEsc,
mergedTheme: themeRef,
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
Expand Down Expand Up @@ -381,7 +390,7 @@ export default defineComponent({
minWidth={this.minWidth}
showMask={this.showMask}
onEsc={this.handleEsc}
onClickoutside={this.handleOutsideClick}
onClickoutside={this.onClickoutside}
>
{this.$slots}
</NDrawerBodyWrapper>
Expand Down
5 changes: 4 additions & 1 deletion src/popover/src/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ export default defineComponent({
clearHideTimer()
doUpdateShow(false)
}
props.onClickoutside?.(e)
// avoid double triggering of right-click events
if (e.button === 0) {
props.onClickoutside?.(e)
}
}
function handleClick (): void {
if (props.trigger === 'click' && !getMergedDisabled()) {
Expand Down
6 changes: 5 additions & 1 deletion src/popselect/src/PopselectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ export default defineComponent({
toggle(tmNode.key)
}
function handleMenuMousedown (e: MouseEvent): void {
if (!happensIn(e, 'action') && !happensIn(e, 'empty')) e.preventDefault()
if (
!happensIn(e, 'action') &&
!happensIn(e, 'empty') &&
!happensIn(e, 'header')
) { e.preventDefault() }
}
function toggle (value: ValueAtom): void {
const {
Expand Down