perf(ui): delegate BxSelect option re-rendering to a single global observer - #1004
Open
Endymi0n74 wants to merge 1 commit into
Open
perf(ui): delegate BxSelect option re-rendering to a single global observer#1004Endymi0n74 wants to merge 1 commit into
Endymi0n74 wants to merge 1 commit into
Conversation
…server Every BxSelectElement.create() was attaching its own MutationObserver to the <select> (subtree + childList + attributes). With many selects in the settings dialogs that is one observer per select, all watching the same document. Now a single static observer watches document.documentElement once and routes mutations to the affected .bx-select wrappers via closest(), only re-rendering selects whose own subtree actually changed (deduplicated with a Set per mutation batch). All other options list re-renders (input, change, value setter) are unchanged. Also removes a leftover `debugger;` statement in Translations.downloadTranslations()'s catch block. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Every
BxSelectElement.create()was attaching its ownMutationObserverto the<select>(subtree + childList + attributes). With many selects in the settings dialogs that's one observer per select, all watching the same document.Now a single static observer watches
document.documentElementonce and routes mutations to the affected.bx-selectwrappers viaclosest(), only re-rendering selects whose own subtree actually changed (deduplicated with aSetper mutation batch). All other re-render triggers (input, change, value setter) are unchanged.Also removes a leftover
debugger;statement inTranslations.downloadTranslations()'s catch block — a no-op in production except pausing the script when the DevTools are open.Why it's safe
closest('.bx-select')targets the same wrappers; the per-select re-render logic is untouched.Setdedup prevents double re-renders within a mutation batch (strictly fewer renders than before).Files
src/web-components/bx-select.ts— static global observer +ensureObserver()+ delegatedonMutationsrc/utils/translation.ts—debugger;removed from the catch blockNote
translation.tsis also touched by the open PRs #908 (mkb zoom), #938 (local co-op) and #468 (record) — all in different regions (the debugger line is ours). Happy to rebase if any of them merges first.