Skip to content

Commit aa08064

Browse files
pfaffeDevtools-frontend LUCI CQ
authored andcommitted
Fix tooltip on variable names
Bug: 401212692 Change-Id: I54a3d974b962f059913a116d6308955dac0e9466 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6357269 Auto-Submit: Philip Pfaffe <[email protected]> Commit-Queue: Eric Leese <[email protected]> Reviewed-by: Eric Leese <[email protected]>
1 parent 62dc5e3 commit aa08064

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

front_end/panels/elements/StylePropertyTreeElement.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class CSSWideKeywordRenderer extends rendererBase(SDK.CSSPropertyParserMa
218218
UI.UIUtils.createTextChild(swatch, match.text);
219219
swatch.data = {
220220
text: match.text,
221-
title: resolvedProperty ? undefined : i18nString(UIStrings.sIsNotDefined, {PH1: match.text}),
221+
tooltip: resolvedProperty ? undefined : {title: i18nString(UIStrings.sIsNotDefined, {PH1: match.text})},
222222
isDefined: Boolean(resolvedProperty),
223223
onLinkActivate: () => resolvedProperty && this.#stylesPane.jumpToDeclaration(resolvedProperty),
224224
jslogContext: 'css-wide-keyword-link',
@@ -340,11 +340,10 @@ export class VariableRenderer extends rendererBase(SDK.CSSPropertyParserMatchers
340340
jslog=${VisualLogging.link('css-variable').track({click: true, hover: true})}
341341
>${varCall}(<devtools-link-swatch
342342
class=css-var-link
343-
aria-details=${tooltipId}
344343
.data=${{
344+
tooltip: {tooltipId},
345345
text: match.name,
346346
isDefined: computedValue !== null && !fromFallback,
347-
title: undefined,
348347
onLinkActivate,
349348
} as InlineEditor.LinkSwatch.LinkSwatchRenderData}
350349
></devtools-link-swatch>${
@@ -860,7 +859,7 @@ export class LinkableNameRenderer extends rendererBase(SDK.CSSPropertyParserMatc
860859
const {metric, jslogContext, ruleBlock, isDefined} = this.#getLinkData(match);
861860
swatch.data = {
862861
text: match.text,
863-
title: isDefined ? undefined : i18nString(UIStrings.sIsNotDefined, {PH1: match.text}),
862+
tooltip: isDefined ? undefined : {title: i18nString(UIStrings.sIsNotDefined, {PH1: match.text})},
864863
isDefined,
865864
onLinkActivate: (): void => {
866865
metric && Host.userMetrics.swatchActivated(metric);

front_end/panels/elements/components/AnchorFunctionLinkSwatch.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describeWithEnvironment('AnchorFunctionLinkSwatch', () => {
4545
assert.isTrue(linkSwatchDataStub.set.calledWith({
4646
text: '--identifier',
4747
isDefined: true,
48-
title: undefined,
48+
tooltip: undefined,
4949
jslogContext: 'anchor-link',
5050
onLinkActivate: sinon.match.func,
5151
}));
@@ -62,7 +62,7 @@ describeWithEnvironment('AnchorFunctionLinkSwatch', () => {
6262
assert.isTrue(linkSwatchDataStub.set.calledWith({
6363
text: '--identifier',
6464
isDefined: false,
65-
title: '--identifier is not defined',
65+
tooltip: {title: '--identifier is not defined'},
6666
jslogContext: 'anchor-link',
6767
onLinkActivate: sinon.match.func,
6868
}));

front_end/panels/elements/components/AnchorFunctionLinkSwatch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ export class AnchorFunctionLinkSwatch extends HTMLElement {
9595
@mouseleave=${this.#data.onMouseLeave}
9696
.data=${{
9797
text: this.#data.identifier,
98-
title: this.#data.anchorNode ? undefined :
99-
i18nString(UIStrings.sIsNotDefined, {PH1: this.#data.identifier}),
98+
tooltip: this.#data.anchorNode ? undefined :
99+
{title: i18nString(UIStrings.sIsNotDefined, {PH1: this.#data.identifier})},
100100
isDefined: Boolean(this.#data.anchorNode),
101101
jslogContext: 'anchor-link',
102102
onLinkActivate: this.#data.onLinkActivate,

front_end/ui/legacy/components/inline_editor/LinkSwatch.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describeWithLocale('LinkSwatch', () => {
3333
const component = new InlineEditor.LinkSwatch.LinkSwatch();
3434
component.data = {
3535
text: 'test',
36-
title: undefined,
36+
tooltip: undefined,
3737
isDefined: true,
3838
onLinkActivate: () => {},
3939
jslogContext: 'test',
@@ -51,7 +51,7 @@ describeWithLocale('LinkSwatch', () => {
5151
const component = new InlineEditor.LinkSwatch.LinkSwatch();
5252
component.data = {
5353
text: 'test',
54-
title: 'test is not defined',
54+
tooltip: {title: 'test is not defined'},
5555
isDefined: false,
5656
onLinkActivate: () => {},
5757
jslogContext: 'test',
@@ -70,7 +70,7 @@ describeWithLocale('LinkSwatch', () => {
7070
let callbackCalled = false;
7171
component.data = {
7272
text: 'testHandler',
73-
title: undefined,
73+
tooltip: undefined,
7474
isDefined: true,
7575
onLinkActivate: () => {
7676
callbackCalled = true;

front_end/ui/legacy/components/inline_editor/LinkSwatch.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import linkSwatchStyles from './linkSwatch.css.js';
1212
const {render, html, nothing, Directives: {ref, ifDefined, classMap}} = Lit;
1313

1414
export interface LinkSwatchRenderData {
15-
title: string|undefined;
15+
tooltip: {tooltipId: string}|{title: string}|undefined;
1616
text: string;
1717
isDefined: boolean;
1818
jslogContext?: string;
@@ -46,7 +46,7 @@ export class LinkSwatch extends HTMLElement {
4646
}
4747

4848
private render(data: LinkSwatchRenderData): void {
49-
const {isDefined, text, jslogContext, title} = data;
49+
const {isDefined, text, jslogContext, tooltip} = data;
5050
const classes = classMap({
5151
'link-style': true,
5252
'text-button': true,
@@ -56,6 +56,9 @@ export class LinkSwatch extends HTMLElement {
5656
// The linkText's space must be removed, otherwise it cannot be triggered when clicked.
5757
const onActivate = isDefined ? this.onLinkActivate.bind(this, text.trim()) : null;
5858

59+
const title = tooltip && 'title' in tooltip && tooltip.title || undefined;
60+
const tooltipId = tooltip && 'tooltipId' in tooltip && tooltip.tooltipId || undefined;
61+
5962
render(
6063
// clang-format off
6164
html`<style>${Buttons.textButtonStyles.cssContent}</style><style>${linkSwatchStyles.cssContent}</style><button
@@ -64,10 +67,11 @@ export class LinkSwatch extends HTMLElement {
6467
class=${classes}
6568
type="button"
6669
title=${ifDefined(title)}
70+
aria-details=${ifDefined(tooltipId)}
6771
@click=${onActivate}
6872
@keydown=${onActivate}
6973
role="link"
70-
tabindex="-1"
74+
tabindex=${ifDefined(isDefined ? -1 : undefined)}
7175
${ref(e => {
7276
this.#linkElement = e as HTMLElement;
7377
})}

0 commit comments

Comments
 (0)