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

feat(flow-item): Add calciteFlowItemScroll event #5547

Merged
merged 3 commits into from
Oct 25, 2022
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
18 changes: 18 additions & 0 deletions src/components/flow-item/flow-item.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,22 @@ describe("calcite-flow-item", () => {

expect(await top.isIntersectingViewport()).toBe(true);
});

it("honors calciteFlowItemScroll event", async () => {
const page = await newE2EPage({
html: "<calcite-flow-item>test</calcite-flow-item>"
});

const scrollSpy = await page.spyOnEvent("calciteFlowItemScroll");

await page.evaluate(() => {
const panel = document.querySelector("calcite-flow-item").shadowRoot.querySelector("calcite-panel");

panel.dispatchEvent(new CustomEvent("calcitePanelScroll"));
});

await page.waitForChanges();

expect(scrollSpy).toHaveReceivedEventTimes(1);
});
});
11 changes: 11 additions & 0 deletions src/components/flow-item/flow-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export class FlowItem implements InteractiveComponent {
*/
@Event({ cancelable: false }) calciteFlowItemBackClick: EventEmitter<void>;

/**
* Fires when the content is scrolled.
*/
@Event({ cancelable: false }) calciteFlowItemScroll: EventEmitter<void>;

/**
* Fires when the close button is clicked.
*/
Expand Down Expand Up @@ -197,6 +202,11 @@ export class FlowItem implements InteractiveComponent {
//
// --------------------------------------------------------------------------

handlePanelScroll = (event: CustomEvent<void>): void => {
event.stopPropagation();
this.calciteFlowItemScroll.emit();
};

handlePanelClose = (event: CustomEvent<void>): void => {
event.stopPropagation();
this.calciteFlowItemClose.emit();
Expand Down Expand Up @@ -282,6 +292,7 @@ export class FlowItem implements InteractiveComponent {
loading={loading}
menuOpen={menuOpen}
onCalcitePanelClose={this.handlePanelClose}
onCalcitePanelScroll={this.handlePanelScroll}
ref={this.setContainerRef}
widthScale={widthScale}
>
Expand Down