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

[Material][Popover] Add support for virtual element as anchorEl #37465

Merged
merged 5 commits into from
Jun 6, 2023

Conversation

DiegoAndai
Copy link
Member

@DiegoAndai DiegoAndai commented Jun 1, 2023

Changes

Add documentation, demo, and tests for using a virtual element (VE) as an anchor element for the Popover component.

Screenshot of the new VE section on the docs

Screenshot of the new VE section

Closes #36416

@DiegoAndai DiegoAndai added docs Improvements or additions to the documentation component: Popover The React component. labels Jun 1, 2023
@mui-bot
Copy link

mui-bot commented Jun 1, 2023

Netlify deploy preview

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 25c8838

@DiegoAndai DiegoAndai requested a review from hbjORbj June 1, 2023 15:38
const selection = window.getSelection();

// Skip if selection has a length of 0
if (!selection || selection.anchorOffset === selection.focusOffset) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this conditional: selection.anchorOffset === selection.focusOffset?

Copy link
Member Author

Choose a reason for hiding this comment

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

It checks that the selection doesn't start and ends at the same character. I tested that you could get that by creating the range programmatically, I don't know if you can get it just by interacting with it. In other words is to make sure that the selection spans at least one character.

DiegoAndai and others added 2 commits June 5, 2023 11:37
@DiegoAndai DiegoAndai requested a review from hbjORbj June 5, 2023 15:47
Copy link
Member

@hbjORbj hbjORbj left a comment

Choose a reason for hiding this comment

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

LGTM!

@DiegoAndai DiegoAndai merged commit 7aa3fab into mui:master Jun 6, 2023
@DiegoAndai DiegoAndai deleted the popover-virtual-element branch June 6, 2023 15:45
@DiegoAndai DiegoAndai self-assigned this Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Popover The React component. docs Improvements or additions to the documentation
Projects
Status: Recently completed
Development

Successfully merging this pull request may close these issues.

[Material][Popover] Can it support VirtualElement like `Popper?
3 participants