Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 7aa19f0

Browse files
authored
fix: prevent multiple command palettes from being added (#178)
1 parent 4f57c04 commit 7aa19f0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/libs/github/inject.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,22 @@ function injectExtensionsGlobalComponents({
320320
}): void {
321321
const headerElem = document.querySelector('div.HeaderMenu>div:last-child')
322322
if (headerElem) {
323-
const commandListElem = document.createElement('div')
324-
commandListElem.className = 'command-palette-button'
325-
headerElem.appendChild(commandListElem)
323+
const commandListClass = 'command-palette-button'
324+
325+
function createCommandList(): HTMLElement {
326+
const commandListElem = document.createElement('div')
327+
commandListElem.className = commandListClass
328+
headerElem!.appendChild(commandListElem)
329+
return commandListElem
330+
}
331+
326332
render(
327333
<CommandListPopoverButton
328334
extensionsController={extensionsController}
329335
menu={ContributableMenu.CommandPalette}
330336
extensions={extensionsContextController}
331337
/>,
332-
commandListElem
338+
document.querySelector('.' + commandListClass) || createCommandList()
333339
)
334340
}
335341
}

0 commit comments

Comments
 (0)