diff --git a/.changeset/rotten-apples-greet.md b/.changeset/rotten-apples-greet.md new file mode 100644 index 0000000000..10d47190d3 --- /dev/null +++ b/.changeset/rotten-apples-greet.md @@ -0,0 +1,5 @@ +--- +'@primer/view-components': patch +--- + +Ensure condition is checked when mutations occur in SelectPanelElement. diff --git a/app/components/primer/alpha/select_panel_element.ts b/app/components/primer/alpha/select_panel_element.ts index e4cb8f6fdb..6987d7b59f 100644 --- a/app/components/primer/alpha/select_panel_element.ts +++ b/app/components/primer/alpha/select_panel_element.ts @@ -250,8 +250,10 @@ export class SelectPanelElement extends HTMLElement { body() } else { const mutationObserver = new MutationObserver(() => { - body() - mutationObserver.disconnect() + if (condition()) { + body() + mutationObserver.disconnect() + } }) mutationObserver.observe(this, {childList: true, subtree: true})