|
1978 | 1978 | } |
1979 | 1979 |
|
1980 | 1980 | function insertNewGlobalBar(element) { |
1981 | | - log(SILENT, 'insertNewGlobalBar()'); |
| 1981 | + log(DEBUG, 'insertNewGlobalBar()'); |
1982 | 1982 |
|
1983 | 1983 | const elementToInsertAfter = HEADER.querySelector(SELECTORS.header.globalBar); |
1984 | 1984 |
|
|
2187 | 2187 |
|
2188 | 2188 | parentUl.insertBefore(newLiElement, settingsLi.nextSibling); |
2189 | 2189 |
|
2190 | | - const divider = featurePreviewLi.parentNode.querySelector('.ActionList-sectionDivider'); |
| 2190 | + const divider = featurePreviewLi.parentNode.querySelector(SELECTORS.sidebars.right.divider); |
| 2191 | + if (!divider) { |
| 2192 | + logError(`Selector '${SELECTORS.sidebars.right.divider}' not found`); |
| 2193 | + return; |
| 2194 | + } |
| 2195 | + |
2191 | 2196 | const newDivider = divider.cloneNode(true); |
2192 | 2197 |
|
2193 | 2198 | parentUl.insertBefore(newDivider, settingsLi.nextSibling); |
|
2301 | 2306 |
|
2302 | 2307 | function gmcOpened() { |
2303 | 2308 | log(DEBUG, 'gmcOpened()'); |
| 2309 | + log(INFO, 'GM_config opened - setting up modal'); |
| 2310 | + |
| 2311 | + const gmcEl = document.querySelector('#gmc'); |
| 2312 | + const gmcFrameEl = document.querySelector('#gmc-frame'); |
| 2313 | + |
| 2314 | + if (gmcEl && gmcFrameEl) { |
| 2315 | + // Create a click barrier that doesn't interfere with the modal |
| 2316 | + gmcEl.addEventListener('click', (e) => { |
| 2317 | + if (e.target === gmcEl) { |
| 2318 | + log(INFO, 'Backdrop clicked - ignoring'); |
| 2319 | + } |
| 2320 | + }); |
| 2321 | + |
| 2322 | + // Focus the modal immediately |
| 2323 | + setTimeout(() => { |
| 2324 | + log(INFO, 'Focusing modal content'); |
| 2325 | + gmcFrameEl.focus(); |
| 2326 | + |
| 2327 | + // Focus first form input for better keyboard navigation |
| 2328 | + const firstInput = gmcFrameEl.querySelector('input, select, button'); |
| 2329 | + if (firstInput) { |
| 2330 | + log(INFO, 'Focusing first input', firstInput); |
| 2331 | + firstInput.focus(); |
| 2332 | + firstInput.click(); |
| 2333 | + } |
| 2334 | + |
| 2335 | + // Make all form controls interactive |
| 2336 | + const allControls = gmcFrameEl.querySelectorAll('input, select, textarea, button, .saveclose_buttons'); |
| 2337 | + allControls.forEach(control => { |
| 2338 | + // Ensure these elements have the highest z-index |
| 2339 | + control.style.zIndex = '10000000'; |
| 2340 | + control.style.position = 'relative'; |
| 2341 | + |
| 2342 | + // Make sure they receive click events |
| 2343 | + control.addEventListener('click', (e) => { |
| 2344 | + log(INFO, 'Control clicked', control); |
| 2345 | + e.stopPropagation(); |
| 2346 | + |
| 2347 | + // Ensure the click is registered by the control |
| 2348 | + if (control.type === 'radio' || control.type === 'checkbox') { |
| 2349 | + log(INFO, 'Toggling input state'); |
| 2350 | + } |
| 2351 | + }); |
| 2352 | + |
| 2353 | + // Ensure the default action happens |
| 2354 | + control.addEventListener('mousedown', (e) => { |
| 2355 | + e.stopPropagation(); |
| 2356 | + }); |
| 2357 | + }); |
| 2358 | + |
| 2359 | + // Special handler for close button |
| 2360 | + const closeButton = gmcFrameEl.querySelector('#gmc-frame_closeBtn'); |
| 2361 | + if (closeButton) { |
| 2362 | + log(INFO, 'Adding special handler for close button'); |
| 2363 | + closeButton.addEventListener('click', (e) => { |
| 2364 | + log(INFO, 'Close button clicked'); |
| 2365 | + e.stopPropagation(); |
| 2366 | + GMC.close(); |
| 2367 | + }); |
| 2368 | + } |
| 2369 | + }, 100); |
| 2370 | + } |
2304 | 2371 |
|
| 2372 | + // Make sure all checkboxes have the proper CSS class |
2305 | 2373 | function updateCheckboxes() { |
2306 | 2374 | log(DEBUG, 'updateCheckboxes()'); |
2307 | 2375 |
|
|
2332 | 2400 | }); |
2333 | 2401 |
|
2334 | 2402 | modifyThenObserve(() => { |
2335 | | - document.querySelector('#gmc-frame .reset_holder').remove(); |
| 2403 | + document.querySelector('#gmc-frame .reset_holder')?.remove(); |
2336 | 2404 |
|
2337 | 2405 | const buttonHolderSelector = '#gmc-frame_buttons_holder'; |
2338 | 2406 | const parentDiv = document.querySelector(buttonHolderSelector); |
|
2344 | 2412 |
|
2345 | 2413 | gmcAddSavedSpan(parentDiv); |
2346 | 2414 | gmcAddNewIssueButton(parentDiv); |
| 2415 | + |
| 2416 | + // Ensure all buttons in the button holder work |
| 2417 | + const buttons = parentDiv.querySelectorAll('button, .saveclose_buttons'); |
| 2418 | + buttons.forEach(button => { |
| 2419 | + button.style.zIndex = '10000001'; |
| 2420 | + button.style.position = 'relative'; |
| 2421 | + button.style.pointerEvents = 'auto'; |
| 2422 | + |
| 2423 | + // Add click handlers to ensure they work |
| 2424 | + button.addEventListener('click', (e) => { |
| 2425 | + log(INFO, 'Button clicked', button); |
| 2426 | + // Don't stop propagation for these to let GM_config handle them |
| 2427 | + }); |
| 2428 | + }); |
2347 | 2429 | }); |
2348 | 2430 |
|
2349 | 2431 | document.querySelector('#gmc').classList.remove('hidden'); |
|
2402 | 2484 |
|
2403 | 2485 | function gmcClosed() { |
2404 | 2486 | log(DEBUG, 'gmcClosed()'); |
| 2487 | + log(INFO, 'GM_config closed'); |
| 2488 | + |
| 2489 | + // GM_config's built-in close functionality will handle most of the cleanup |
2405 | 2490 |
|
2406 | 2491 | switch (GMC.get('on_close')) { |
2407 | 2492 | case 'refresh tab': |
|
2511 | 2596 | left: 0 !important; |
2512 | 2597 | width: 100vw !important; |
2513 | 2598 | height: 100vh !important; |
2514 | | - z-index: 9999; |
2515 | | - background: none !important; |
2516 | | -
|
2517 | | - pointer-events: none; |
| 2599 | + z-index: 9999999 !important; |
| 2600 | + background: rgba(0, 0, 0, 0.5) !important; |
| 2601 | + pointer-events: all !important; |
| 2602 | + backdrop-filter: blur(2px); |
2518 | 2603 | } |
2519 | 2604 |
|
2520 | 2605 | #gmc.hidden |
|
2532 | 2617 | max-height: initial !important; |
2533 | 2618 | max-width: initial !important; |
2534 | 2619 | opacity: 1 !important; |
2535 | | - position: static !important; |
2536 | | - z-index: initial !important; |
| 2620 | + position: relative !important; |
| 2621 | + z-index: 9999999 !important; |
2537 | 2622 |
|
2538 | 2623 | width: 85% !important; |
2539 | 2624 | height: 75% !important; |
|
2542 | 2627 | border: none !important; |
2543 | 2628 | border-radius: 0.375rem !important; |
2544 | 2629 |
|
2545 | | - pointer-events: auto; |
| 2630 | + pointer-events: all !important; |
2546 | 2631 | } |
2547 | 2632 |
|
2548 | 2633 | #gmc-frame_wrapper |
2549 | 2634 | { |
2550 | 2635 | display: flow-root !important; |
2551 | 2636 | padding: 2rem !important; |
| 2637 | + pointer-events: auto !important; |
| 2638 | + } |
| 2639 | +
|
| 2640 | + /* Make all form controls in the modal prioritized */ |
| 2641 | + #gmc-frame input, |
| 2642 | + #gmc-frame select, |
| 2643 | + #gmc-frame textarea, |
| 2644 | + #gmc-frame button, |
| 2645 | + #gmc-frame .field_label, |
| 2646 | + #gmc-frame .radio_label, |
| 2647 | + #gmc-frame label, |
| 2648 | + #gmc-frame .saveclose_buttons, |
| 2649 | + #gmc-frame [type=button] |
| 2650 | + { |
| 2651 | + z-index: 10000000 !important; |
| 2652 | + pointer-events: auto !important; |
2552 | 2653 | } |
2553 | 2654 |
|
2554 | 2655 | /* Sections */ |
|
3198 | 3299 | log(DEBUG, 'gmcBuildFrame()'); |
3199 | 3300 |
|
3200 | 3301 | const body = document.querySelector('body'); |
3201 | | - const gmcDiv = document.createElement('div'); |
3202 | 3302 |
|
| 3303 | + // Create main modal container |
| 3304 | + const gmcDiv = document.createElement('div'); |
3203 | 3305 | gmcDiv.setAttribute('id', 'gmc'); |
3204 | 3306 | gmcDiv.classList.add('hidden'); |
3205 | 3307 |
|
| 3308 | + // Add modal to document |
3206 | 3309 | body.appendChild(gmcDiv); |
3207 | 3310 |
|
| 3311 | + // Create frame |
3208 | 3312 | const gmcFrameDiv = document.createElement('div'); |
3209 | 3313 | gmcFrameDiv.setAttribute('id', 'gmc-frame'); |
| 3314 | + gmcFrameDiv.setAttribute('tabindex', '0'); |
3210 | 3315 |
|
3211 | 3316 | gmcDiv.appendChild(gmcFrameDiv); |
3212 | 3317 |
|
|
3500 | 3605 | closeButton: '.AppHeader-user .Overlay--placement-right .Overlay-closeButton.close-button', |
3501 | 3606 | navParentDiv: '.AppHeader-user .Overlay--placement-right div.Overlay-body > div', |
3502 | 3607 | nav: '.AppHeader-user .Overlay--placement-right nav', |
| 3608 | + divider: 'li[data-component="ActionList.Divider"]', |
3503 | 3609 | }, |
3504 | 3610 | }, |
3505 | 3611 | }; |
|
0 commit comments