Skip to content

Commit e51ec36

Browse files
committed
Fix divider in settings
1 parent 279a3f8 commit e51ec36

File tree

1 file changed

+117
-11
lines changed

1 file changed

+117
-11
lines changed

src/github-custom-global-navigation.user.js

Lines changed: 117 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@
19781978
}
19791979

19801980
function insertNewGlobalBar(element) {
1981-
log(SILENT, 'insertNewGlobalBar()');
1981+
log(DEBUG, 'insertNewGlobalBar()');
19821982

19831983
const elementToInsertAfter = HEADER.querySelector(SELECTORS.header.globalBar);
19841984

@@ -2187,7 +2187,12 @@
21872187

21882188
parentUl.insertBefore(newLiElement, settingsLi.nextSibling);
21892189

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+
21912196
const newDivider = divider.cloneNode(true);
21922197

21932198
parentUl.insertBefore(newDivider, settingsLi.nextSibling);
@@ -2301,7 +2306,70 @@
23012306

23022307
function gmcOpened() {
23032308
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+
}
23042371

2372+
// Make sure all checkboxes have the proper CSS class
23052373
function updateCheckboxes() {
23062374
log(DEBUG, 'updateCheckboxes()');
23072375

@@ -2332,7 +2400,7 @@
23322400
});
23332401

23342402
modifyThenObserve(() => {
2335-
document.querySelector('#gmc-frame .reset_holder').remove();
2403+
document.querySelector('#gmc-frame .reset_holder')?.remove();
23362404

23372405
const buttonHolderSelector = '#gmc-frame_buttons_holder';
23382406
const parentDiv = document.querySelector(buttonHolderSelector);
@@ -2344,6 +2412,20 @@
23442412

23452413
gmcAddSavedSpan(parentDiv);
23462414
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+
});
23472429
});
23482430

23492431
document.querySelector('#gmc').classList.remove('hidden');
@@ -2402,6 +2484,9 @@
24022484

24032485
function gmcClosed() {
24042486
log(DEBUG, 'gmcClosed()');
2487+
log(INFO, 'GM_config closed');
2488+
2489+
// GM_config's built-in close functionality will handle most of the cleanup
24052490

24062491
switch (GMC.get('on_close')) {
24072492
case 'refresh tab':
@@ -2511,10 +2596,10 @@
25112596
left: 0 !important;
25122597
width: 100vw !important;
25132598
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);
25182603
}
25192604
25202605
#gmc.hidden
@@ -2532,8 +2617,8 @@
25322617
max-height: initial !important;
25332618
max-width: initial !important;
25342619
opacity: 1 !important;
2535-
position: static !important;
2536-
z-index: initial !important;
2620+
position: relative !important;
2621+
z-index: 9999999 !important;
25372622
25382623
width: 85% !important;
25392624
height: 75% !important;
@@ -2542,13 +2627,29 @@
25422627
border: none !important;
25432628
border-radius: 0.375rem !important;
25442629
2545-
pointer-events: auto;
2630+
pointer-events: all !important;
25462631
}
25472632
25482633
#gmc-frame_wrapper
25492634
{
25502635
display: flow-root !important;
25512636
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;
25522653
}
25532654
25542655
/* Sections */
@@ -3198,15 +3299,19 @@
31983299
log(DEBUG, 'gmcBuildFrame()');
31993300

32003301
const body = document.querySelector('body');
3201-
const gmcDiv = document.createElement('div');
32023302

3303+
// Create main modal container
3304+
const gmcDiv = document.createElement('div');
32033305
gmcDiv.setAttribute('id', 'gmc');
32043306
gmcDiv.classList.add('hidden');
32053307

3308+
// Add modal to document
32063309
body.appendChild(gmcDiv);
32073310

3311+
// Create frame
32083312
const gmcFrameDiv = document.createElement('div');
32093313
gmcFrameDiv.setAttribute('id', 'gmc-frame');
3314+
gmcFrameDiv.setAttribute('tabindex', '0');
32103315

32113316
gmcDiv.appendChild(gmcFrameDiv);
32123317

@@ -3500,6 +3605,7 @@
35003605
closeButton: '.AppHeader-user .Overlay--placement-right .Overlay-closeButton.close-button',
35013606
navParentDiv: '.AppHeader-user .Overlay--placement-right div.Overlay-body > div',
35023607
nav: '.AppHeader-user .Overlay--placement-right nav',
3608+
divider: 'li[data-component="ActionList.Divider"]',
35033609
},
35043610
},
35053611
};

0 commit comments

Comments
 (0)