Skip to content

Commit

Permalink
fix(calcite-button): Make shadow dom button 100% width (#9145)
Browse files Browse the repository at this point in the history
**Related Issue:** #8490

## Summary
When the host element button is set to "full" the shadow dom button is set to 100% width to span the entire space.

---------

Co-authored-by: Matt Driscoll <mdriscoll@esri.com>
  • Loading branch information
josercarcamo and driskull committed May 1, 2024
1 parent 1ad530e commit dd61b7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/calcite-components/src/components/button/button.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,4 +747,15 @@ describe("calcite-button", () => {
expect(button.getAttribute("aria-expanded")).toBe("true");
expect(calciteButton.getAttribute("aria-expanded")).toBe("true");
});

it("renders child element with same width as host", async () => {
const page = await newE2EPage();
await page.setContent(`<calcite-button width="full">Continue</calcite-button>`);
const elementHost = await page.find("calcite-button");
const elementAsButton = await page.find("calcite-button >>> button");
expect(elementHost).not.toBeNull();
expect(elementAsButton).not.toBeNull();
expect(elementHost).toEqualAttribute("width", "full");
expect(await elementAsButton.getComputedStyle()["width"]).toEqual(await elementHost.getComputedStyle()["width"]);
});
});
10 changes: 10 additions & 0 deletions packages/calcite-components/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,16 @@
@apply text-0h w-11;
min-block-size: theme("height.11");
}

:host(:is([scale="s"], [scale="m"], [scale="l"])[width="full"]) {
a,
button {
&:not(.content--slotted) {
inline-size: var(--calcite-container-size-content-fluid);
}
}
}

// accommodate for transparent buttons not having borders
:host([scale="l"][appearance="transparent"]) button:not(.content--slotted),
:host([scale="l"][appearance="transparent"]) a:not(.content--slotted) {
Expand Down

0 comments on commit dd61b7f

Please sign in to comment.