File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed
src/unfold/static/unfold/js Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -135,15 +135,26 @@ const dateTimeShortcutsOverlay = () => {
135135 * File upload path
136136 *************************************************************/
137137const fileInputUpdatePath = ( ) => {
138- Array . from ( document . querySelectorAll ( "input[type=file]" ) ) . forEach ( ( input ) => {
139- input . addEventListener ( "change" , ( e ) => {
140- const parts = e . target . value . split ( "\\" ) ;
141- const placeholder =
142- input . parentNode . parentNode . parentNode . querySelector (
143- "input[type=text]"
144- ) ;
145- placeholder . setAttribute ( "value" , parts [ parts . length - 1 ] ) ;
146- } ) ;
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+ }
151+ }
152+ }
153+ } ) ;
154+
155+ observer . observe ( document . body , {
156+ childList : true ,
157+ subtree : true ,
147158 } ) ;
148159} ;
149160
You can’t perform that action at this time.
0 commit comments