Skip to content

Commit

Permalink
fix(button, list, pick-list, value-list)!: prevent loading prop from …
Browse files Browse the repository at this point in the history
…affecting interactivity (#8292)

**Related Issue:** #7590

This updates some components to avoid setting `disabled` on internal,
supporting components when `loading` was set to true.

BREAKING CHANGE: Setting `loading` prop to true no longer prevents
interaction nor applies disabled styles. If you'd like to block
interaction when loading, please set `disabled` along with `loading`.
  • Loading branch information
jcfranco authored and benelan committed Dec 2, 2023
1 parent a3230ac commit db3c5c7
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 38 deletions.
9 changes: 0 additions & 9 deletions packages/calcite-components/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,6 @@

@include disabled();

:host([loading]:not([disabled])) {
@extend %non-interactive-host-contents;

button,
a {
@apply opacity-disabled;
}
}

@keyframes loader-in {
0% {
inline-size: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class Button
name={childElType === "button" && this.name}
onClick={this.handleClick}
rel={childElType === "a" && this.rel}
tabIndex={this.disabled || this.loading ? -1 : null}
tabIndex={this.disabled ? -1 : null}
target={childElType === "a" && this.target}
title={this.tooltipText}
type={childElType === "button" && this.type}
Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export class List
/>
<calcite-filter
aria-label={filterPlaceholder}
disabled={loading || disabled}
disabled={disabled}
items={dataForFilter}
onCalciteFilterChange={this.handleFilterChange}
placeholder={filterPlaceholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
focusing,
itemRemoval,
keyboardNavigation,
loadingState,
selectionAndDeselection,
} from "./shared-list-tests";

Expand Down Expand Up @@ -195,10 +194,6 @@ describe("calcite-pick-list", () => {
itemRemoval("pick");
});

describe("loading state", () => {
loadingState("pick");
});

describe("setFocus", () => {
focusing("pick");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const List: FunctionalComponent<{ props: ListProps } & DOMAttributes<any>
{filterEnabled ? (
<calcite-filter
aria-label={filterPlaceholder}
disabled={loading || disabled}
disabled={disabled}
items={dataForFilter}
onCalciteFilterChange={handleFilterEvent}
placeholder={filterPlaceholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,22 +548,6 @@ export function filterBehavior(listType: ListType): void {
});
}

export function loadingState(listType: ListType): void {
it("loading", async () => {
const page = await newE2EPage();
await page.setContent(`<calcite-${listType}-list loading>
<calcite-${listType}-list-item value="one" label="One"></calcite-${listType}-list-item>
</calcite-${listType}-list>`);

const list = await page.find(`calcite-${listType}-list`);
const item1 = await list.find("[value=one]");
const toggleSpy = await list.spyOnEvent("calciteListChange");

await item1.click();
expect(toggleSpy).toHaveReceivedEventTimes(0);
});
}

export function itemRemoval(listType: ListType): void {
const pickListGroupHtml = html` <calcite-pick-list-group
label="Will be removed when slotted 'parent item' is removed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
focusing,
itemRemoval,
keyboardNavigation,
loadingState,
selectionAndDeselection,
} from "../pick-list/shared-list-tests";
import { CSS, ICON_TYPES } from "./resources";
Expand Down Expand Up @@ -99,10 +98,6 @@ describe("calcite-value-list", () => {
itemRemoval("value");
});

describe("loading state", () => {
loadingState("value");
});

describe("setFocus", () => {
focusing("value");
});
Expand Down

0 comments on commit db3c5c7

Please sign in to comment.