Skip to content
Open
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
90 changes: 23 additions & 67 deletions packages/main/cypress/specs/ColorPalettePopover.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,75 +543,42 @@ describe("Color Popover Palette arrow keys navigation", () => {
});

describe("Color Popover Palette Home and End keyboard navigation", () => {
it.skip("should navigate with Home/End when showDefaultColor is set", () => {
it("should navigate with Home/End when showDefaultColor is set", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} />
);

cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

cy.get("[ui5-color-palette-popover]")
.should("have.attr", "open");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteInPopover()
.as("colorPalette");

cy.get("@colorPalette")
.ui5GetColorPaletteDefaultButton()
.as("defaultColorButton")
.should("be.visible")
.and("have.focus");

cy.get("@defaultColorButton")
.should("have.focus")
.shadow()
.find("button[data-sap-focus-ref]")
.should("have.focus");
// Default Color button should be focused initially
cy.focused()
.should("have.attr", "aria-label", "Default Color");

cy.get("@defaultColorButton")
// End → last color item (red)
cy.focused()
.realPress("End");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteItem(3)
.as("lastColorPaletteItem")
.should("be.visible")
.and("have.attr", "value", "red");

cy.get("@lastColorPaletteItem")
.should("have.focus")
.shadow()
.find(".ui5-cp-item")
cy.focused()
.should("have.attr", "tabindex", "0")
.and("have.attr", "aria-label")
.and("include", "red");

// Home → first color item (cyan)
cy.focused()
.realPress("Home");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteItem(0)
.as("firstColorPaletteItem")
.should("be.visible")
.and("have.attr", "value", "cyan");

cy.get("@firstColorPaletteItem")
.should("have.focus")
.shadow()
.find(".ui5-cp-item")
cy.focused()
.should("have.attr", "tabindex", "0")
.and("have.attr", "aria-label")
.and("include", "cyan");

// Home again → Default Color button
cy.focused()
.realPress("Home");

cy.focused()
.should("have.attr", "aria-label", "Default Color");

cy.get("@defaultColorButton")
.should("have.focus");
});

it("should navigate with Home/End keys when showMoreColors is set", () => {
Expand Down Expand Up @@ -640,42 +607,31 @@ describe("Color Popover Palette Home and End keyboard navigation", () => {
.should("have.attr", "aria-label", "More Colors...");
});

it.skip("should navigate with Home/End when showDefaultColor & showMoreColors are set", () => {
it("should navigate with Home/End when showDefaultColor & showMoreColors are set", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} showMoreColors={true} />
);

cy.get<ColorPalettePopover>("[ui5-color-palette-popover]")
.as("colorPalettePopover")
cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

cy.get<ColorPalette>("@colorPalettePopover")
.ui5GetColorPaletteInPopover()
.as("colorPalette");

cy.get("@colorPalette")
.ui5GetColorPaletteDefaultButton()
.as("defaultColorButton");
// Default Color button should be focused initially
cy.focused()
.should("have.attr", "aria-label", "Default Color");

cy.get("@defaultColorButton")
.should("have.focus")
// End → More Colors button
cy.focused()
.realPress("End");

cy.get("@colorPalette")
.ui5GetColorPaletteMoreColorsButton()
.as("moreColorsButton")
.should("be.visible");

cy.get("@moreColorsButton")
.should("exist")
.and("be.visible")
.and("have.focus");
cy.focused()
.should("have.attr", "aria-label", "More Colors...");

cy.get("@moreColorsButton")
// Home → Default Color button
cy.focused()
.realPress("Home");

cy.get("@defaultColorButton")
.should("have.focus");
cy.focused()
.should("have.attr", "aria-label", "Default Color");
});

it("should navigate with End key", () => {
Expand Down
12 changes: 7 additions & 5 deletions packages/main/src/ColorPaletteTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export default function ColorPaletteTemplate(this: ColorPalette) {
onMouseDown={this._onmousedown}
>
{this.showDefaultColor &&
<div class="ui5-cp-default-color-button-wrapper">
<div class="ui5-cp-default-color-button-wrapper"
onKeyDown={this._onDefaultColorKeyDown}
onKeyUp={this._onDefaultColorKeyUp}
>
<Button
class="ui5-cp-default-color-button"
design="Transparent"
onClick={this._onDefaultColorClick}
onKeyUp={this._onDefaultColorKeyUp}
onKeyDown={this._onDefaultColorKeyDown}
>
{this.colorPaletteDefaultColorText}
</Button>
Expand All @@ -42,13 +43,14 @@ export default function ColorPaletteTemplate(this: ColorPalette) {
</div>

{this.showMoreColors &&
<div class="ui5-cp-more-colors-wrapper">
<div class="ui5-cp-more-colors-wrapper"
onKeyDown={this._onMoreColorsKeyDown}
>
<div class="ui5-cp-separator"></div>
<Button
design="Transparent"
class="ui5-cp-more-colors"
onClick={this._openMoreColorsDialog}
onKeyDown={this._onMoreColorsKeyDown}
>
{this.colorPaletteMoreColorsText}
</Button>
Expand Down
Loading