Skip to content

Commit c97e195

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[ui] Fix <devtools-named-bit-set-filter> loosing styling.
This regressed as part of https://crrev.com/c/6216262, which replaced the `adoptedStyleSheets` with a `<style>` element, but the `options` setter would afterwards wipe the shadow DOM. Bug: 391381439 Change-Id: I6effbdd4e2ac9ec850e729f5688234ca1dc9ba92 Fixed: 394105224 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6229629 Reviewed-by: Danil Somsikov <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Commit-Queue: Danil Somsikov <[email protected]>
1 parent e286048 commit c97e195

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

front_end/ui/legacy/FilterBar.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import filterStyles from './filter.css.js';
4141
import {KeyboardShortcut, Modifiers} from './KeyboardShortcut.js';
4242
import {bindCheckbox} from './SettingsUI.js';
4343
import type {Suggestions} from './SuggestBox.js';
44-
import * as ThemeSupport from './theme_support/theme_support.js';
4544
import {type ToolbarButton, ToolbarFilter, ToolbarInput, ToolbarSettingToggle} from './Toolbar.js';
4645
import {Tooltip} from './Tooltip.js';
4746
import {CheckboxLabel, createTextChild} from './UIUtils.js';
@@ -274,6 +273,11 @@ interface NamedBitSetFilterUIOptions {
274273
items: Item[];
275274
setting?: Common.Settings.Setting<{[key: string]: boolean}>;
276275
}
276+
277+
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
278+
const filterStyleSheet = new CSSStyleSheet();
279+
filterStyleSheet.replaceSync(filterStyles.cssContent);
280+
277281
export class NamedBitSetFilterUIElement extends HTMLElement {
278282
#options: NamedBitSetFilterUIOptions = {items: []};
279283
readonly #shadow = this.attachShadow({mode: 'open'});
@@ -311,7 +315,9 @@ export class NamedBitSetFilterUIElement extends HTMLElement {
311315
}
312316

313317
connectedCallback(): void {
314-
ThemeSupport.ThemeSupport.instance().appendStyle(this.#shadow, filterStyles);
318+
// TODO(crbug.com/391381439): We cannot simply add a `<style>` element here, because
319+
// the `options` setter above clears the shadow DOM.
320+
this.#shadow.adoptedStyleSheets = [filterStyleSheet];
315321
}
316322

317323
#filterChanged(): void {

0 commit comments

Comments
 (0)