-
Notifications
You must be signed in to change notification settings - Fork 165
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
[scoped-custom-element-registry]: Disabled attribute blocks any click on custom elements (all the WebComponents are form-associated) #547
Comments
The polyfill also prevents setting focus on disabled custom elements that explicitly have a Use case: I am creating a As shown in the lit.dev playground example above, the polyfill prevents disabled elements from receiving focus at all, even when tabindex is present. Native elements will receive focus when |
👋 Hello! I've also come across some obscure behaviour, which seems to be directly related to this. I'm unsure exactly how to reproduce this as a minimal example, but this polyfill setting Unfortunately, I think we're going to have to remove this polyfill entirely because of these unpredictable issues, and specifically go down a route of not scoping anything.… Unless there a chance this issue can be addressed? |
Unfortunately, there's not a great fix for this since WorkaroundBefore loading the polyfill, apply a script like the following. This ensures <script>(function() {
window.formAssociatedCustomElementTags = new Set();
const nativeDefine = customElements.define.bind(customElements);
customElements.define = (name, ctor) => {
if (!window.formAssociatedCustomElementTags.has(name)) {
Object.defineProperty(ctor, 'formAssociated', {value: false, configurable: true});
}
nativeDefine(name, ctor);
}
})();</script>
<script src="scoped-custom-element-registry.min.js"></script> |
Description
WebComponents defined with the scoped-custom-element-registry polyfill not receive any click event when they have the disabled attribute set.
The polyfill seems to be setting the
formAssociated
static getter to all the WebComponents registered with the polyfill enabled which cause all the WebComponents to behave like an input, button, textarea, etc.polyfills/packages/scoped-custom-element-registry/src/scoped-custom-element-registry.js
Lines 217 to 220 in 90cb97f
As it enables the
formAssociated
property, it blocks any click from the user when the component is disabled something that should only happen on real form components like button, fieldset , optgroup , option , select, textarea and input as defined in https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabledThis is not the only issue detected, other users also seems to find strange behaviours with the polyfill enabled like in the issue #546
Example
Steps to reproduce
my-element
my-element
to document.body of the previously created index.htmlExpected behavior
Any element which is not really associated with a form or a form element should be able to behave as a normal WebComponent and not as a form-associated WebComponent
Actual behavior
All the WebComponents are form-associated when the polyfill is loaded
Version
This is issue has been happening from the version 0.0.4 and onwards of the scoped-custom-element-registry polyfill.
Browsers affected
The text was updated successfully, but these errors were encountered: