@@ -135,27 +135,33 @@ const dateTimeShortcutsOverlay = () => {
135135 * File upload path
136136 *************************************************************/
137137const fileInputUpdatePath = ( ) => {
138- const observer = new MutationObserver ( ( mutations ) => {
139- for ( const mutation of mutations ) {
140- if ( mutation . type === "childList" ) {
141- for ( const input of document . querySelectorAll ( "input[type=file]" ) ) {
142- input . addEventListener ( "change" , ( e ) => {
143- const parts = e . target . value . split ( "\\" ) ;
144- const placeholder =
145- input . parentNode . parentNode . parentNode . querySelector (
146- "input[type=text]"
147- ) ;
148- placeholder . setAttribute ( "value" , parts [ parts . length - 1 ] ) ;
149- } ) ;
150- }
138+ const checkInputChanged = ( ) => {
139+ for ( const input of document . querySelectorAll ( "input[type=file]" ) ) {
140+ if ( input . hasChangeListener ) {
141+ continue ;
151142 }
143+
144+ input . addEventListener ( "change" , ( e ) => {
145+ const parts = e . target . value . split ( "\\" ) ;
146+ const placeholder =
147+ input . parentNode . parentNode . parentNode . querySelector (
148+ "input[type=text]"
149+ ) ;
150+ placeholder . setAttribute ( "value" , parts [ parts . length - 1 ] ) ;
151+ } ) ;
152+
153+ input . hasChangeListener = true ;
152154 }
153- } ) ;
155+ } ;
154156
155- observer . observe ( document . body , {
157+ new MutationObserver ( ( ) => {
158+ checkInputChanged ( ) ;
159+ } ) . observe ( document . body , {
156160 childList : true ,
157161 subtree : true ,
158162 } ) ;
163+
164+ checkInputChanged ( ) ;
159165} ;
160166
161167/*************************************************************
0 commit comments