MCPcopy
hub / github.com/refined-github/refined-github / handleMenuOpening

Function handleMenuOpening

source/features/restore-file.tsx:164–187  ·  view source on GitHub ↗
({delegateTarget: menuButton}: DelegateEvent)

Source from the content-addressed store, hash-verified

162}
163
164function handleMenuOpening({delegateTarget: menuButton}: DelegateEvent): void {
165 // Don't run if the menu has been closed
166 if (menuButton.ariaExpanded === 'false') {
167 return;
168 }
169
170 // Track the file container for later removal
171 focusedFileContainer = closestElement('div[id^="diff-"]', menuButton);
172
173 // Wait for the menu DOM to be created, but not rendered
174 requestAnimationFrame(() => {
175 const editFile = $('[class^="prc-ActionList-ActionListItem"]:has(.octicon-pencil)');
176 const discardItem = editFile.cloneNode(true);
177 discardItem.classList.add('rgh-restore-file');
178 const link = $('a', discardItem);
179 link.ariaKeyShortcuts = 'd';
180 link.removeAttribute('href');
181 link.removeAttribute('aria-labelledby');
182 $('[class^="prc-ActionList-ItemLabel"]', discardItem).textContent = 'Discard changes';
183 $('[class^="prc-ActionList-LeadingVisual"]', discardItem).replaceChildren(<UndoIcon />);
184
185 editFile.after(discardItem);
186 });
187}
188
189async function init(signal: AbortSignal): Promise<void> {
190 // Legacy view

Callers

nothing calls this directly

Calls 1

cloneNodeMethod · 0.80

Tested by

no test coverage detected