@@ -183,31 +183,16 @@ class App {
183183 }
184184
185185 setupEventListeners ( ) {
186- // Click to upload - use label approach for better browser compatibility
187- // The label wraps the file input, so clicking anywhere on upload area triggers it
188- const fileInputLabel = this . uploadArea . querySelector ( '.file-input-label' ) ;
189- if ( fileInputLabel ) {
190- // Make label cover entire upload area
191- fileInputLabel . style . position = 'absolute' ;
192- fileInputLabel . style . top = '0' ;
193- fileInputLabel . style . left = '0' ;
194- fileInputLabel . style . width = '100%' ;
195- fileInputLabel . style . height = '100%' ;
196- fileInputLabel . style . cursor = 'pointer' ;
197- fileInputLabel . style . zIndex = '1' ;
198- // Ensure label is clickable
199- fileInputLabel . style . pointerEvents = 'auto' ;
200- }
201-
202- // Direct click handler on upload area as primary method
186+ // File input is positioned absolutely over upload area, so clicking anywhere opens it
187+ // Also handle direct clicks on upload area as fallback
203188 this . uploadArea . addEventListener ( 'click' , ( e ) => {
204189 // Don't trigger if clicking on remove button or other interactive elements
205190 if ( e . target . closest ( '.remove-file' ) || e . target . closest ( '.btn' ) ) {
206191 return ;
207192 }
208- // Trigger file input click directly
209- if ( this . fileInput && e . target !== this . fileInput ) {
210- // Small delay to ensure event propagation
193+ // If click is not on file input itself, trigger it
194+ if ( this . fileInput && e . target !== this . fileInput && ! e . target . closest ( 'input[type="file"]' ) ) {
195+ // Use setTimeout for better compatibility
211196 setTimeout ( ( ) => {
212197 try {
213198 this . fileInput . click ( ) ;
@@ -223,7 +208,8 @@ class App {
223208 if ( e . target . closest ( '.remove-file' ) || e . target . closest ( '.btn' ) ) {
224209 return ;
225210 }
226- if ( this . fileInput && e . target !== this . fileInput ) {
211+ if ( this . fileInput && e . target !== this . fileInput && ! e . target . closest ( 'input[type="file"]' ) ) {
212+ // Prevent default to avoid conflicts
227213 e . preventDefault ( ) ;
228214 setTimeout ( ( ) => {
229215 try {
@@ -575,7 +561,7 @@ async function init() {
575561 // Load JSZip and initialize app
576562 await loadJSZip ( ) ;
577563 window . JSZip = JSZip ;
578- new App ( ) ;
564+ window . app = new App ( ) ; // Save app instance for testing
579565 } catch ( error ) {
580566 console . error ( 'Failed to initialize:' , error ) ;
581567 const errorDiv = document . createElement ( 'div' ) ;
0 commit comments