Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flow): Call setFocus() on back button click #7285

Merged
merged 29 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cdc61e8
feat(flow): Adds setFocus method.
driskull Jun 30, 2023
10e1feb
Merge branch 'master' into dris0000/flow-setFocus
driskull Jun 30, 2023
832fca8
cleanup
driskull Jun 30, 2023
a77567e
Merge branch 'dris0000/flow-setFocus' of github.com:Esri/calcite-comp…
driskull Jun 30, 2023
631cc0e
cleanup
driskull Jun 30, 2023
f539560
add test
driskull Jun 30, 2023
9162ff6
fix test
driskull Jun 30, 2023
e38dc24
remove test
driskull Jun 30, 2023
0a68b0f
remove test
driskull Jun 30, 2023
9a85dfb
return setfocus
driskull Jun 30, 2023
1877df6
cleanup
driskull Jun 30, 2023
4203482
revert
driskull Jun 30, 2023
2ab4139
cleanup
driskull Jun 30, 2023
c4e4eca
Merge branch 'master' into dris0000/flow-setFocus
driskull Jun 30, 2023
1a7dcc1
Merge branch 'main' into dris0000/flow-setFocus
driskull Jul 3, 2023
dbad9fb
Merge branch 'main' into dris0000/flow-setFocus
driskull Jul 3, 2023
ea509bd
cleanup
driskull Jul 3, 2023
34e4755
cleanup
driskull Jul 3, 2023
094ff3a
Merge branch 'main' into dris0000/flow-setFocus
driskull Jul 3, 2023
13fe6a4
Merge branch 'main' into dris0000/flow-setFocus
driskull Jul 3, 2023
c4c4bb8
Merge branch 'main' into dris0000/flow-setFocus
driskull Jul 3, 2023
11fecec
cleanup
driskull Jul 3, 2023
fbe2fca
Merge branch 'main' into dris0000/flow-setFocus
driskull Jul 5, 2023
c3904aa
feat(flow): Adds setFocus method
driskull Jul 5, 2023
1fcd48a
fix(flow): Call setFocus() on back click
driskull Jul 5, 2023
f512a1f
add test
driskull Jul 5, 2023
c058ece
Merge branch 'main' into dris0000/flow-call-setFocus-on-back
driskull Jul 5, 2023
3397241
review fixes
driskull Jul 5, 2023
086558c
cleanup
driskull Jul 5, 2023
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
22 changes: 22 additions & 0 deletions packages/calcite-components/src/components/flow/flow.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { html } from "../../../support/formatting";
import { accessible, focusable, hidden, renders } from "../../tests/commonTests";
import { CSS as ITEM_CSS } from "../flow-item/resources";
import { CSS } from "./resources";
import { isElementFocused } from "../../tests/utils";

describe("calcite-flow", () => {
describe("renders", () => {
Expand Down Expand Up @@ -55,6 +56,27 @@ describe("calcite-flow", () => {
expect(flowItem).toBeNull();
});

it("should call setFocus() on back button click", async () => {
const page = await newE2EPage();

await page.setContent(
html`<calcite-flow
><calcite-flow-item id="one"></calcite-flow-item><calcite-flow-item id="two"></calcite-flow-item
></calcite-flow>`
);

await page.$eval(
"#two",
(elm: HTMLCalciteFlowItemElement, backButtonCSS: string) => {
elm.shadowRoot.querySelector<HTMLCalciteActionElement>(`.${backButtonCSS}`)?.click();
},
ITEM_CSS.backButton
);
await page.waitForChanges();

await isElementFocused(page, "#one");
});

it("goes back when item back button is clicked", async () => {
const page = await newE2EPage();

Expand Down
5 changes: 3 additions & 2 deletions packages/calcite-components/src/components/flow/flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ export class Flow implements LoadableComponent {
// --------------------------------------------------------------------------

@Listen("calciteFlowItemBack")
handleItemBackClick(): void {
this.back();
async handleItemBackClick(): Promise<void> {
await this.back();
return this.setFocus();
}

getFlowDirection = (oldFlowItemCount: number, newFlowItemCount: number): FlowDirection | null => {
Expand Down