Skip to content

fix(input-date-picker): Correctly position open component when scrolling #6815

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

Merged
merged 6 commits into from
Apr 24, 2023

Conversation

driskull
Copy link
Member

@driskull driskull commented Apr 19, 2023

Related Issue: #6463

Summary

Sets up floating UI when the component is opened in order to get all scrollable parents.

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Apr 19, 2023
@@ -644,6 +644,7 @@ export class InputDatePicker

transitionEl: HTMLDivElement;

@Watch("open")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfranco the problem seems to be when the input-date-picker is rendered the floatingEl has no parent yet. Not sure if its because it's not rendered or if some other stuff isn't ready yet.

So if we watch for open and then setup the floating ui again it can get all the scrolling parents correctly.

Seems like this is the only component affected.

@driskull driskull marked this pull request as ready for review April 21, 2023 17:51
@driskull driskull requested a review from a team as a code owner April 21, 2023 17:51
@driskull driskull requested a review from jcfranco April 21, 2023 20:22
@@ -654,7 +654,7 @@ export class InputDatePicker
? endWrapper || startWrapper
: startWrapper || endWrapper;

connectFloatingUI(this, this.referenceEl, this.floatingEl);
requestAnimationFrame(() => connectFloatingUI(this, this.referenceEl, this.floatingEl));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to wait for next frame to connect floating UI because some rendering is still going on. The rendering needs to happen first before trying to get all scrollable parents.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. On a related note, I was thinking input-date-picker should be refactored to use popover for consistency and reusability. Maybe that would help eliminate since this doesn't appear to be an issue with the input-time-picker.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think that makes sense since popover has a role of "dialog" and those two components seem to open dialogs. For things like combobox using the popover, we would need to be able to modify the role.

@driskull driskull added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Apr 22, 2023
@jcfranco jcfranco changed the title fix(date-picker): Correctly position open component when scrolling fix(input-date-picker): Correctly position open component when scrolling Apr 22, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -580,4 +580,39 @@ describe("calcite-input-date-picker", () => {
expect(changeEvent).toHaveReceivedEventTimes(1);
expect(await datepickerEl.getProperty("value")).toEqual(["2022-08-15", "2022-08-20"]);
});

it("should position on scroll when overlayPositioning is fixed", async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Could you try using commonTests#floatingUIOwner? It should cover scrolling updates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test already has a floatingUIOwner test. Maybe it should be updated to test with overlay-positioning="fixed" as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this and it passed so its not catching the issue.

 it("owns a floating-ui 2", () =>
    floatingUIOwner(
      `<calcite-input-date-picker overlay-positioning="fixed" value="2022-11-27" min="2022-11-15" max="2024-11-15"></calcite-input-date-picker>`,
      "open",
      { shadowSelector: ".menu-container" }
    ));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I think the helper might need some tweaking. Can you create a follow-up issue for me? Let's proceed with the existing test here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created: #6838

@@ -654,7 +654,7 @@ export class InputDatePicker
? endWrapper || startWrapper
: startWrapper || endWrapper;

connectFloatingUI(this, this.referenceEl, this.floatingEl);
requestAnimationFrame(() => connectFloatingUI(this, this.referenceEl, this.floatingEl));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. On a related note, I was thinking input-date-picker should be refactored to use popover for consistency and reusability. Maybe that would help eliminate since this doesn't appear to be an issue with the input-time-picker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants