mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-26 04:27:26 +08:00
refactor(hooks): [useFocusController] add disabled attribute (#21032)
refactor(hooks): [useFocusController] add disabled prop Co-authored-by: warmthsea <2586244885@qq.com>
This commit is contained in:
@ -92,6 +92,15 @@ export const useSelect = (props: SelectProps, emit: SelectEmits) => {
|
||||
const tagMenuRef = ref<HTMLElement>()
|
||||
const collapseItemRef = ref<HTMLElement>()
|
||||
const scrollbarRef = ref<ScrollbarInstance>()
|
||||
// the controller of the expanded popup
|
||||
const expanded = ref(false)
|
||||
const hoverOption = ref()
|
||||
|
||||
const { form, formItem } = useFormItem()
|
||||
const { inputId } = useFormItemInputId(props, {
|
||||
formItemContext: formItem,
|
||||
})
|
||||
const { valueOnClear, isEmptyValue } = useEmptyValues(props)
|
||||
|
||||
const {
|
||||
isComposing,
|
||||
@ -102,10 +111,10 @@ export const useSelect = (props: SelectProps, emit: SelectEmits) => {
|
||||
afterComposition: (e) => onInput(e),
|
||||
})
|
||||
|
||||
const selectDisabled = computed(() => props.disabled || !!form?.disabled)
|
||||
|
||||
const { wrapperRef, isFocused, handleBlur } = useFocusController(inputRef, {
|
||||
beforeFocus() {
|
||||
return selectDisabled.value
|
||||
},
|
||||
disabled: selectDisabled,
|
||||
afterFocus() {
|
||||
if (props.automaticDropdown && !expanded.value) {
|
||||
expanded.value = true
|
||||
@ -127,18 +136,6 @@ export const useSelect = (props: SelectProps, emit: SelectEmits) => {
|
||||
},
|
||||
})
|
||||
|
||||
// the controller of the expanded popup
|
||||
const expanded = ref(false)
|
||||
const hoverOption = ref()
|
||||
|
||||
const { form, formItem } = useFormItem()
|
||||
const { inputId } = useFormItemInputId(props, {
|
||||
formItemContext: formItem,
|
||||
})
|
||||
const { valueOnClear, isEmptyValue } = useEmptyValues(props)
|
||||
|
||||
const selectDisabled = computed(() => props.disabled || form?.disabled)
|
||||
|
||||
const hasModelValue = computed(() => {
|
||||
return isArray(props.modelValue)
|
||||
? props.modelValue.length > 0
|
||||
|
Reference in New Issue
Block a user