Skip to content

Commit

Permalink
fix(QInput): lazy model + clearable - not emitting "change" event on …
Browse files Browse the repository at this point in the history
…clear btn
  • Loading branch information
rstoenescu committed May 8, 2024
1 parent 899d55a commit 2040e2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/input/QInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default createComponent({

const onComposition = useKeyComposition(onInput)

const state = useFieldState()
const state = useFieldState({ hasChangeEvent: true })

const isTextarea = computed(() =>
props.type === 'textarea' || props.autogrow === true
Expand Down
4 changes: 3 additions & 1 deletion ui/src/composables/private.use-field/use-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const useFieldProps = {

export const useFieldEmits = [ 'update:modelValue', 'clear', 'focus', 'blur' ]

export function useFieldState ({ requiredForAttr = true, tagProp } = {}) {
export function useFieldState ({ requiredForAttr = true, tagProp, hasChangeEvent = false } = {}) {
const { props, proxy } = getCurrentInstance()

const isDark = useDark(props, proxy.$q)
Expand All @@ -82,6 +82,7 @@ export function useFieldState ({ requiredForAttr = true, tagProp } = {}) {

return {
requiredForAttr,
hasChangeEvent,
tag: tagProp === true
? computed(() => props.tag)
: { value: 'label' },
Expand Down Expand Up @@ -343,6 +344,7 @@ export default function (state) {
}

emit('update:modelValue', null)
state.hasChangeEvent === true && emit('change', null)
emit('clear', props.modelValue)

nextTick(() => {
Expand Down

0 comments on commit 2040e2a

Please sign in to comment.