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

TypeAheadMenu and TableActionMenu rendered off screen fixed. #4301

Merged
merged 7 commits into from
May 11, 2023

Conversation

Shubhankerism
Copy link
Collaborator

@Shubhankerism Shubhankerism commented Apr 11, 2023

In this PR, the issue related to the TypeAheadMenu and TableActionMenu rendered off screen is addressed.

Issue:

TypeAheadMenu rendered offscreen.
image

TableActionMenu rendered offscreen.
image

After changes:

image

image

@vercel
Copy link

vercel bot commented Apr 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2023 5:01pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2023 5:01pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 11, 2023
@Shubhankerism Shubhankerism changed the title added offset values TypeAheadMenu and TableActionMenu rendered off screen Apr 11, 2023
@Shubhankerism Shubhankerism changed the title TypeAheadMenu and TableActionMenu rendered off screen TypeAheadMenu and TableActionMenu rendered off screen fixed. Apr 11, 2023
@ivailop7
Copy link
Collaborator

Thank you, Shubhanker! This addresses #3834.

Copy link
Collaborator

@ivailop7 ivailop7 left a comment

Choose a reason for hiding this comment

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

Minor thing. Otherwise LGTM.

dropDownElement.style.opacity = '1';
const dropDownElementRect = dropDownElement.getBoundingClientRect();
let leftPosition = menuButtonRect.right + 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

No magic numbers please, please put the 5 in a const above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Ivo, thanks for the review :) I have replaced the number with a const now.

Copy link
Member

@zurfyx zurfyx left a comment

Choose a reason for hiding this comment

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

Wow thank you! Been looking forward to seeing this menu fixed for many months now 🥹

@tylerjbainbridge mind having a pass to it, particularly the Typeahead area?


const rootElementRect = rootElement.getBoundingClientRect();

if (left + menuWidth > rootElementRect.right) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's incorrect to overlap the menu over other screen elements (even when this goes off the editor boundaries). However, when this goes beyond the viewport then that's a problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @zurfyx, thanks for the feedback. :)

@@ -600,11 +600,33 @@ function useMenuAnchorRef(
const positionMenu = useCallback(() => {
const rootElement = editor.getRootElement();
const containerDiv = anchorElementRef.current;

if (rootElement !== null && resolution !== null) {
const menuEle = containerDiv.getElementsByTagName('ul');
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think hardcoding the ul is the right approach here.

That's how all of the playground typeaheads are configured, but we can't be sure that every outside user of the Plugin will implement it this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @tylerjbainbridge thanks for the review :) Now instead of using the ul element, I am referring to the TypeAheadMenu by ul element's parent div with the class name typeahead-popover component-picker-menu.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @Shubhankerism, unfortunately this still won't work because we can't count on those classes being applied to every typeahead. That's just how they're styled in our playground.

Let's use

const menuEle = containerDiv.firstChild;

for now.

It's not perfect, but it'll be more robust than the other solutions. We can work on passing in a ref or something later on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @tylerjbainbridge , thanks for the feedback. I have made the changes as you suggested.


if (rootElement !== null && resolution !== null) {
const menuEle = containerDiv.getElementsByTagName('ul');
if (rootElement !== null && resolution !== null && menuEle.length !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no ul in the menu's children it will skip over all of the positioning code here.

Copy link
Contributor

@tylerjbainbridge tylerjbainbridge left a comment

Choose a reason for hiding this comment

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

See previous comment

Copy link
Contributor

@tylerjbainbridge tylerjbainbridge left a comment

Choose a reason for hiding this comment

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

LGTM!

@zurfyx
Copy link
Member

zurfyx commented Apr 18, 2023

Can we please look into the 9 failing E2E tests before we can merge this? They seem to be consistently failing across platforms.

@Shubhankerism
Copy link
Collaborator Author

Can we please look into the 9 failing E2E tests before we can merge this? They seem to be consistently failing across platforms.

Hi @zurfyx , I have pulled the recent changes from main and made the change that fixed the failing E2E tests. Can you please review it? Thanks :)

@tylerjbainbridge tylerjbainbridge merged commit d10c4e6 into facebook:main May 11, 2023
39 of 43 checks passed
@Shubhankerism Shubhankerism deleted the popup-menu-fix branch May 11, 2023 20:17
This was referenced May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants