fix: select dropdown custom input error #7020
parent
380fcd4aa9
commit
4428423be4
|
@ -510,7 +510,6 @@ export default defineComponent({
|
||||||
// ========================== Focus / Blur ==========================
|
// ========================== Focus / Blur ==========================
|
||||||
/** Record real focus status */
|
/** Record real focus status */
|
||||||
const focusRef = shallowRef(false);
|
const focusRef = shallowRef(false);
|
||||||
|
|
||||||
const onContainerFocus: FocusEventHandler = (...args) => {
|
const onContainerFocus: FocusEventHandler = (...args) => {
|
||||||
setMockFocused(true);
|
setMockFocused(true);
|
||||||
|
|
||||||
|
@ -527,14 +526,16 @@ export default defineComponent({
|
||||||
|
|
||||||
focusRef.value = true;
|
focusRef.value = true;
|
||||||
};
|
};
|
||||||
|
const popupFocused = ref(false);
|
||||||
const onContainerBlur: FocusEventHandler = (...args) => {
|
const onContainerBlur: FocusEventHandler = (...args) => {
|
||||||
|
if (popupFocused.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
blurRef.value = true;
|
blurRef.value = true;
|
||||||
|
|
||||||
setMockFocused(false, () => {
|
setMockFocused(false, () => {
|
||||||
focusRef.value = false;
|
focusRef.value = false;
|
||||||
blurRef.value = false;
|
blurRef.value = false;
|
||||||
//onToggleOpen(false);
|
onToggleOpen(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.disabled) {
|
if (props.disabled) {
|
||||||
|
@ -557,6 +558,12 @@ export default defineComponent({
|
||||||
props.onBlur(...args);
|
props.onBlur(...args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const onPopupFocusin = () => {
|
||||||
|
popupFocused.value = true;
|
||||||
|
};
|
||||||
|
const onPopupFocusout = () => {
|
||||||
|
popupFocused.value = false;
|
||||||
|
};
|
||||||
provide('VCSelectContainerEvent', {
|
provide('VCSelectContainerEvent', {
|
||||||
focus: onContainerFocus,
|
focus: onContainerFocus,
|
||||||
blur: onContainerBlur,
|
blur: onContainerBlur,
|
||||||
|
@ -818,6 +825,8 @@ export default defineComponent({
|
||||||
getTriggerDOMNode={() => selectorDomRef.current}
|
getTriggerDOMNode={() => selectorDomRef.current}
|
||||||
onPopupVisibleChange={onTriggerVisibleChange}
|
onPopupVisibleChange={onTriggerVisibleChange}
|
||||||
onPopupMouseEnter={onPopupMouseEnter}
|
onPopupMouseEnter={onPopupMouseEnter}
|
||||||
|
onPopupFocusin={onPopupFocusin}
|
||||||
|
onPopupFocusout={onPopupFocusout}
|
||||||
v-slots={{
|
v-slots={{
|
||||||
default: () => {
|
default: () => {
|
||||||
return customizeRawInputElement ? (
|
return customizeRawInputElement ? (
|
||||||
|
|
|
@ -71,6 +71,8 @@ export interface SelectTriggerProps {
|
||||||
onPopupVisibleChange?: (visible: boolean) => void;
|
onPopupVisibleChange?: (visible: boolean) => void;
|
||||||
|
|
||||||
onPopupMouseEnter: () => void;
|
onPopupMouseEnter: () => void;
|
||||||
|
onPopupFocusin: () => void;
|
||||||
|
onPopupFocusout: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
|
const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
|
||||||
|
@ -97,6 +99,8 @@ const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
|
||||||
getTriggerDOMNode: Function,
|
getTriggerDOMNode: Function,
|
||||||
onPopupVisibleChange: Function as PropType<(open: boolean) => void>,
|
onPopupVisibleChange: Function as PropType<(open: boolean) => void>,
|
||||||
onPopupMouseEnter: Function,
|
onPopupMouseEnter: Function,
|
||||||
|
onPopupFocusin: Function,
|
||||||
|
onPopupFocusout: Function,
|
||||||
} as any,
|
} as any,
|
||||||
setup(props, { slots, attrs, expose }) {
|
setup(props, { slots, attrs, expose }) {
|
||||||
const builtInPlacements = computed(() => {
|
const builtInPlacements = computed(() => {
|
||||||
|
@ -129,6 +133,8 @@ const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
|
||||||
getTriggerDOMNode,
|
getTriggerDOMNode,
|
||||||
onPopupVisibleChange,
|
onPopupVisibleChange,
|
||||||
onPopupMouseEnter,
|
onPopupMouseEnter,
|
||||||
|
onPopupFocusin,
|
||||||
|
onPopupFocusout,
|
||||||
} = restProps as SelectTriggerProps;
|
} = restProps as SelectTriggerProps;
|
||||||
const dropdownPrefixCls = `${prefixCls}-dropdown`;
|
const dropdownPrefixCls = `${prefixCls}-dropdown`;
|
||||||
|
|
||||||
|
@ -167,7 +173,12 @@ const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
|
||||||
v-slots={{
|
v-slots={{
|
||||||
default: slots.default,
|
default: slots.default,
|
||||||
popup: () => (
|
popup: () => (
|
||||||
<div ref={popupRef} onMouseenter={onPopupMouseEnter}>
|
<div
|
||||||
|
ref={popupRef}
|
||||||
|
onMouseenter={onPopupMouseEnter}
|
||||||
|
onFocusin={onPopupFocusin}
|
||||||
|
onFocusout={onPopupFocusout}
|
||||||
|
>
|
||||||
{popupNode}
|
{popupNode}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue