Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ describe("calcite-action-bar", () => {
);
});

describe("messageOverrides", () => {
it("should honor expandLabel and collapseLabel", async () => {
const page = await newE2EPage();

await page.setContent("<calcite-action-bar></calcite-action-bar>");
await page.waitForChanges();

const actionBar = await page.find("calcite-action-bar");

const expandLabel = "Open me up";
const collapseLabel = "Close me down";

actionBar.setProperty("messageOverrides", {
expandLabel,
collapseLabel,
});
await page.waitForChanges();

const expandAction = await page.find("calcite-action-bar >>> #expand-toggle");

expect(expandAction).not.toBeNull();

expect(await expandAction.getProperty("label")).toBe(expandLabel);

actionBar.setProperty("expanded", true);
await page.waitForChanges();

expect(await expandAction.getProperty("label")).toBe(collapseLabel);
});
});

describe("expand functionality", () => {
it("should not modify actions within an action-menu", async () => {
const page = await newE2EPage({
Expand Down Expand Up @@ -109,7 +140,7 @@ describe("calcite-action-bar", () => {

await page.waitForChanges();

const expandAction = await page.find("calcite-action-bar >>> calcite-action");
const expandAction = await page.find("calcite-action-bar >>> #expand-toggle");

expect(expandAction).not.toBeNull();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ export class ActionBar

const expandToggleNode = !expandDisabled ? (
<ExpandToggle
collapseLabel={messages.collapseLabel}
collapseText={messages.collapse}
el={el}
expandLabel={messages.expandLabel}
expandText={messages.expand}
expanded={expanded}
position={position}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"expand": "Expand",
"collapse": "Collapse"
"collapse": "Collapse",
"expandLabel": "Expand",
"collapseLabel": "Collapse"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"expand": "Expand",
"collapse": "Collapse"
"collapse": "Collapse",
"expandLabel": "Expand",
"collapseLabel": "Collapse"
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,37 @@ describe("calcite-action-pad", () => {
);
});

describe("messageOverrides", () => {
it("should honor expandLabel and collapseLabel", async () => {
const page = await newE2EPage();

await page.setContent("<calcite-action-pad></calcite-action-pad>");
await page.waitForChanges();

const actionPad = await page.find("calcite-action-pad");

const expandLabel = "Open me up";
const collapseLabel = "Close me down";

actionPad.setProperty("messageOverrides", {
expandLabel,
collapseLabel,
});
await page.waitForChanges();

const expandAction = await page.find("calcite-action-pad >>> #expand-toggle");

expect(expandAction).not.toBeNull();

expect(await expandAction.getProperty("label")).toBe(expandLabel);

actionPad.setProperty("expanded", true);
await page.waitForChanges();

expect(await expandAction.getProperty("label")).toBe(collapseLabel);
});
});

describe("expand functionality", () => {
it("should be expandable by default", async () => {
const page = await newE2EPage();
Expand All @@ -85,7 +116,7 @@ describe("calcite-action-pad", () => {

await page.waitForChanges();

const expandAction = await page.find("calcite-action-pad >>> calcite-action");
const expandAction = await page.find("calcite-action-pad >>> #expand-toggle");

expect(expandAction).not.toBeNull();
});
Expand All @@ -97,7 +128,7 @@ describe("calcite-action-pad", () => {

await page.waitForChanges();

const expandAction = await page.find("calcite-action-pad >>> calcite-action");
const expandAction = await page.find("calcite-action-pad >>> #expand-toggle");

expect(expandAction).toBeNull();
});
Expand Down Expand Up @@ -187,7 +218,7 @@ describe("calcite-action-pad", () => {
</calcite-action-pad>`,
);

const expandAction = await page.find("calcite-action-pad >>> calcite-action");
const expandAction = await page.find("calcite-action-pad >>> #expand-toggle");
const action = await page.find("calcite-action");
const actionPad = await page.find("calcite-action-pad");
const group = await page.find("calcite-action-group");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,10 @@ export class ActionPad

const expandToggleNode = !expandDisabled ? (
<ExpandToggle
collapseLabel={messages.collapseLabel}
collapseText={messages.collapse}
el={el}
expandLabel={messages.expandLabel}
expandText={messages.expand}
expanded={expanded}
position={position}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"expand": "Expand",
"collapse": "Collapse"
"collapse": "Collapse",
"expandLabel": "Expand",
"collapseLabel": "Collapse"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"expand": "Expand",
"collapse": "Collapse"
"collapse": "Collapse",
"expandLabel": "Expand",
"collapseLabel": "Collapse"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface ExpandToggleProps {
expanded: boolean;
expandText: string;
collapseText: string;
expandLabel: string;
collapseLabel: string;
el: HTMLElement;
position: Position;
tooltip?: HTMLCalciteTooltipElement;
Expand Down Expand Up @@ -66,6 +68,8 @@ export const ExpandToggle: FunctionalComponent<ExpandToggleProps> = ({
expanded,
expandText,
collapseText,
expandLabel,
collapseLabel,
toggle,
el,
position,
Expand All @@ -76,6 +80,7 @@ export const ExpandToggle: FunctionalComponent<ExpandToggleProps> = ({
const rtl = getElementDir(el) === "rtl";

const text = expanded ? collapseText : expandText;
const label = expanded ? collapseLabel : expandLabel;
const icons = [ICONS.chevronsLeft, ICONS.chevronsRight];

if (rtl) {
Expand All @@ -89,6 +94,8 @@ export const ExpandToggle: FunctionalComponent<ExpandToggleProps> = ({
const actionNode = (
<calcite-action
icon={expanded ? expandIcon : collapseIcon}
id="expand-toggle"
label={label}
onClick={toggle}
ref={(referenceElement): HTMLCalciteActionElement =>
setTooltipReference({ tooltip, referenceElement, expanded, ref })
Expand Down