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!: floating-ui elements no longer take up space when closed #10241

Merged
merged 56 commits into from
Oct 31, 2024

Conversation

driskull
Copy link
Member

@driskull driskull commented Sep 6, 2024

Related Issue: #10240

Summary

  • Sets floating element dimensions to zero when not open
    • This makes sure that a closed floating-ui element doesn't produce scrollbars within a parent element.
    • This is handled by setting the style on the floating element container to display:none when not open.
  • [Popover, Tooltip]: Moves position styles from the host to an internal element to avoid style clashes.
    • This is better because the positioning styles won't interfere with any light DOM styling
    • This added benefit is less CSS in the floating-ui CSS file.
  • display:none is removed in the onClose of the component so that the animation can finish before its set to be hidden.
    • This restores closing animation in floating ui elements.
  • Cleanup floating-ui methods
  • Add story
  • Update tests

Avoids closed floating ui elements from affecting layout changes. Example:

image

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Sep 6, 2024
@driskull driskull marked this pull request as ready for review September 6, 2024 19:47
@driskull driskull added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Sep 6, 2024
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Sep 6, 2024
@driskull driskull removed the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Sep 9, 2024
@jcfranco
Copy link
Member

jcfranco commented Sep 9, 2024

Before reviewing, could you confirm the following issues are still handled by these changes?

#1381
#5694

I recall we moved away from -999...9px values in the past.

@driskull
Copy link
Member Author

driskull commented Sep 9, 2024

#1381 should not be an issue since we are using inset-inline which will not cause scrollbars in RTL direction.

#5694 seems to be an issue with this PR so I guess that would be a showstopper.

The problem with not positioning off screen is that it will affect the size of the parent container.

Maybe once we implement the dialog element and popover attribute it will not be an issue any longer.

For now, I'll close this PR since it causes issues with drag and drop and elements positioned offscreen.

@jcfranco
Copy link
Member

jcfranco commented Sep 9, 2024

Thanks for testing. Bummer about #5694. 😞

@driskull
Copy link
Member Author

driskull commented Sep 9, 2024

If I set the width and height to 0 instead of positioning it offscreen that seems to do the trick. I'll do some more testing.

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.

I have a few follow-up comments, but this is great, @driskull! ✨💪✨

…m:Esri/calcite-design-system into dris0000/floating-ui-position-when-closed
@driskull driskull added the breaking change Issues and pull requests with code changes that are not backwards compatible. label Oct 1, 2024
@driskull driskull marked this pull request as draft October 1, 2024 21:45
# Conflicts:
#	packages/calcite-components/src/components/input-time-picker/input-time-picker.tsx
#	packages/calcite-components/src/components/popover/popover.e2e.ts
# Conflicts:
#	packages/calcite-components/src/components/input-date-picker/input-date-picker.e2e.ts
#	packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx
@driskull driskull marked this pull request as ready for review October 28, 2024 20:29
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.

LGTM!

Could you update the PR title and description to match our breaking change formatting? For the breaking change footer, feel free to use notes from our 3.x. breaking change doc.

This can be merged after the Oct milestone wraps up.

import { CSS } from "./resources";

describe("calcite-popover", () => {
describe("renders", () => {
renders("calcite-popover", { visible: false, display: "block" });
renders("calcite-popover", { display: "block" });
renders(`<calcite-popover label="test" open reference-element="ref"></calcite-popover><div id="ref">😄</div>`, {
Copy link
Member

Choose a reason for hiding this comment

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

This can be done in a follow-up, but can you wrap one of these renders in a describe block? Nested tests need a separate block since our test helpers use the same names for describe/it calls.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixing

@@ -1848,6 +1848,13 @@ export const panelWithPopoverZIndex = (): string =>
</calcite-flow-item>
</calcite-flow>
</calcite-shell-panel> </calcite-shell
><calcite-popover open reference-element="button" offset-distance="-50" offset-skidding="15" style="z-index: 100">
><calcite-popover
overlay-positioning="fixed"
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why this is needed now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its not needed, ill revert the change. The panel inside the popover just needs a width here. Ill update the test.

@driskull driskull changed the title fix: floating-ui elements no longer take up space when closed fix!: floating-ui elements no longer take up space when closed Oct 29, 2024
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 31, 2024
@driskull driskull added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Oct 31, 2024
# Conflicts:
#	packages/calcite-components/src/components/dropdown/dropdown.e2e.ts
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 31, 2024
driskull added a commit that referenced this pull request Oct 31, 2024
)

**Related Issue:** #7537

## Summary

- depends on #10241
- updates `action` to allow cursor to be overriden
- lists should set the `label` property for the "Move to" sorting menu
to have a name for the list.
- adds `calcite-sort-handle` component to handle sorting and moving
between lists for non mouse users
  - internal component 
  - adds stories
  - adds tests 
- list-item
  - deprecates `dragSelected` property: no longer needed.
- deprecates `calciteListItemDragHandleChange` event. no longer needed.
- removed setting `aria-posinset` and `aria-setsize`. These are only
needed when only part of the items are availalbe in the DOM. So we can
safely remove these.
-
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-setsize
-
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-posinset
- replaces `calcite-handle` with `calcite-sort-handle` in the `list`
component.
- updates tests
- adds tests
- adds demo pages

BREAKING CHANGE: Modifies the component's keyboard sorting experience by
using a dropdown menu to move list items. The ListItem `dragSelected`
property and `calciteListItemDragHandleChange` event have been removed
due to no longer being relevant.
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 31, 2024
@driskull driskull merged commit 91d9b2e into dev Oct 31, 2024
13 checks passed
@driskull driskull deleted the dris0000/floating-ui-position-when-closed branch October 31, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Issues and pull requests with code changes that are not backwards compatible. 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