@@ -36,24 +36,22 @@ class Pattern extends BasePattern {
3636 this . set_state ( ) ;
3737
3838 for ( const input of this . handler . getAllInputs ( ) ) {
39+ // Note: One input can be a dependency for multiple other dependent
40+ // elements. Therefore we need to bind the events not uniquely and
41+ // add a uuid to the event bindings id.
42+
3943 events . add_event_listener (
4044 input ,
41- "change" ,
42- `pat-depends--change--${ this . uuid } ` , // We need to support multiple events per dependant ...
43- this . set_state . bind ( this )
44- ) ;
45- events . add_event_listener (
46- input ,
47- "keyup" ,
48- `pat-depends--keyup--${ this . uuid } ` , // ... therefore we need to add a uuid to the event id ...
45+ "input" ,
46+ `pat-depends--input--${ this . uuid } ` ,
4947 this . set_state . bind ( this )
5048 ) ;
5149
5250 if ( input . form ) {
5351 events . add_event_listener (
5452 input . form ,
5553 "reset" ,
56- `pat-depends--reset--${ this . uuid } ` , // ... to not override previously set event handlers.
54+ `pat-depends--reset--${ this . uuid } ` ,
5755 async ( ) => {
5856 // TODO: note sure, what this timeout is for.
5957 await utils . timeout ( 50 ) ;
@@ -77,8 +75,9 @@ class Pattern extends BasePattern {
7775 const inputs = dom . find_inputs ( this . el ) ;
7876 for ( const input of inputs ) {
7977 input . disabled = false ;
80- // Trigger the change event after disabling so that any other bound actions can react on that.
81- input . dispatchEvent ( events . change_event ( ) ) ;
78+ // Trigger the input after disabling so that any other bound
79+ // actions can react on that.
80+ input . dispatchEvent ( events . input_event ( ) ) ;
8281 }
8382 if ( this . el . tagName === "A" ) {
8483 events . remove_event_listener ( this . el , "pat-depends--click" ) ;
@@ -96,8 +95,9 @@ class Pattern extends BasePattern {
9695 const inputs = dom . find_inputs ( this . el ) ;
9796 for ( const input of inputs ) {
9897 input . disabled = true ;
99- // Trigger the change event after disabling so that any other bound actions can react on that.
100- input . dispatchEvent ( events . change_event ( ) ) ;
98+ // Trigger the input after disabling so that any other bound
99+ // actions can react on that.
100+ input . dispatchEvent ( events . input_event ( ) ) ;
101101 }
102102 if ( this . el . tagName === "A" ) {
103103 events . add_event_listener ( this . el , "click" , "pat-depends--click" , ( e ) =>
0 commit comments