Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
fix(action): When using tooltips with an action, browsers title popup…
Browse files Browse the repository at this point in the history
… shows up (#872)

* #871 don't automatically set title on the button. Let the user set the title on the action if they want it. This is to allow them to create tooltips.

* fix test
  • Loading branch information
driskull authored Mar 3, 2020
1 parent 108cb7b commit 0c1fa41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/components/calcite-action/calcite-action.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ describe("calcite-action", () => {
await page.setContent(`<calcite-action text="hello world"></calcite-action>`);

const button = await page.find(`calcite-action >>> .${CSS.button}`);
expect(button.getAttribute("title")).toBe("hello world");
expect(button.getAttribute("aria-label")).toBe("hello world");
});

Expand All @@ -81,7 +80,6 @@ describe("calcite-action", () => {
await page.setContent(`<calcite-action text="hello world" label="hi"></calcite-action>`);

const button = await page.find(`calcite-action >>> .${CSS.button}`);
expect(button.getAttribute("title")).toBe("hi");
expect(button.getAttribute("aria-label")).toBe("hi");
});

Expand Down
6 changes: 2 additions & 4 deletions src/components/calcite-action/calcite-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ export class CalciteAction {
render() {
const { compact, disabled, loading, el, textEnabled, label, text } = this;

const titleText = !textEnabled && text;
const title = label || titleText;
const ariaLabel = label || (!textEnabled && text);
const rtl = getElementDir(el) === "rtl";

const buttonClasses = {
Expand All @@ -167,8 +166,7 @@ export class CalciteAction {
<Host>
<button
class={classnames(CSS.button, buttonClasses)}
title={title}
aria-label={title}
aria-label={ariaLabel}
disabled={disabled}
aria-disabled={disabled.toString()}
aria-busy={loading.toString()}
Expand Down

0 comments on commit 0c1fa41

Please sign in to comment.