[select] overrides native change
event to CustomEvent
globally
#679
Labels
bug
Something isn't working
change
event to CustomEvent
globally
#679
Describe the bug:
forge-select
currently re-emits achange
event asCustomEvent
with adetail
property of the selected value or values. It also changes the type in the globalHTMLElementEventMap
to match, which causes all change handlers on any element, including a native input or select, to be typed asCustomEvent
instead ofEvent
.With strict TypeScript configurations, this causes incorrect types to be inferred in some scenarios, and also causes compilation errors when used in conjunction with certain libraries (such as CKEditor) whose type declarations make certain assumptions that are rendered invalid, e.g.:
![image](https://private-user-images.githubusercontent.com/9934982/362710199-d21d2c0e-371a-4569-99d8-58834a853022.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTY5MzUsIm5iZiI6MTczOTYxNjYzNSwicGF0aCI6Ii85OTM0OTgyLzM2MjcxMDE5OS1kMjFkMmMwZS0zNzFhLTQ1NjktOTlkOC01ODgzNGE4NTMwMjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTVUMTA1MDM1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NGFjZWY2ODBjNzMwMzU5MTkzNjI3MGRlNWZkMmIwOGM4MmY4MDYzMzU2ZDQ0N2IxYjM4YTkyOGM1NTE4MjU0ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.vrlZ0r3CWNPtFPXo7pcaR1VsENvsoZv32wJssoHOuO4)
To Reproduce:
Steps to reproduce the behavior:
change
event in anaddEventListener
invocation in a TypeScript app.Expected behavior:
The type declaration for
change
should be removed. The component could still re-emit the nativechange
event if desirable, but should emit aforge-select-change
event, which can be typed asCustomEvent
.Screenshots:
![image](https://private-user-images.githubusercontent.com/9934982/362710112-251c4cf5-8d44-4993-878d-fc4e3678b17f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTY5MzUsIm5iZiI6MTczOTYxNjYzNSwicGF0aCI6Ii85OTM0OTgyLzM2MjcxMDExMi0yNTFjNGNmNS04ZDQ0LTQ5OTMtODc4ZC1mYzRlMzY3OGIxN2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTVUMTA1MDM1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDUyZWYxOGJhNDViZjY1YWQwYWE4NDhmMmI1YWQ4Mjc1ODhmNWEyNmQzMzUxYzMzZjYwYjBlY2E1MWI1N2E5NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.D7vg56fU07WiQNNFMbNyoF2v4xBpHD5WtTJdlCEgH08)
Please complete the following information:
Additional context:
The text was updated successfully, but these errors were encountered: