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

refactor(switch): update component #480

Draft
wants to merge 7 commits into
base: ts
Choose a base branch
from

Conversation

Cr0zy07
Copy link
Collaborator

@Cr0zy07 Cr0zy07 commented Jan 3, 2024

Description

Linked Issues

cc #358

Additional context

Copy link
Contributor

github-actions bot commented Jan 3, 2024

Thank you for following the naming conventions! 🙏

Comment on lines +34 to +45
watchEffect(() => {
const input = inputRef.value!
const inputProto = window.HTMLInputElement.prototype
const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor
const setChecked = descriptor.set

if (prevChecked.value !== checked.value && setChecked) {
const event = new Event('click', { bubbles: bubbles.value })
setChecked.call(input, checked.value)
input.dispatchEvent(event)
}
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bubble-input does not bubble up checked change, I'm not sure if there is an issue here or not.

Comment on lines 90 to 99
if (isFormControl.value) {
// TODO: isPropagationStopped() is not supported in vue
// hasConsumerStoppedPropagationRef.value = event.isPropagationStopped()

// if switch is in a form, stop propagation from the button so that we only propagate
// one click event (from the input). We propagate changes from an input so that native
// form validation works and form events reflect switch updates.
if (!hasConsumerStoppedPropagationRef.value)
event.stopPropagation()
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or the bubble up events issue is related to this.

@Cr0zy07 Cr0zy07 marked this pull request as ready for review January 4, 2024 03:11
@Cr0zy07 Cr0zy07 marked this pull request as draft January 5, 2024 12:52
@productdevbook productdevbook changed the base branch from main to ts January 13, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant