Skip to content

TypeAheadMenu and TableActionMenu rendered off screen fixed. - #4301

Merged
tylerjbainbridge merged 7 commits into
meta:mainfrom
Shubhankerism:popup-menu-fix
May 11, 2023
Merged

tylerjbainbridge merged 7 commits into
meta:mainfrom
Shubhankerism:popup-menu-fix

Conversation

@Shubhankerism

@Shubhankerism Shubhankerism commented Apr 11, 2023 •

Copy link
Copy Markdown
Contributor

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

vercel Bot commented Apr 11, 2023 •

Copy link
Copy Markdown

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
Copy Markdown
Collaborator

Thank you, Shubhanker! This addresses #3834.

@ivailop7 ivailop7 left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Contributor 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.

@zurfyx zurfyx left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Contributor 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. :)

const containerDiv = anchorElementRef.current;

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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.

@tylerjbainbridge tylerjbainbridge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See previous comment

@tylerjbainbridge tylerjbainbridge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@zurfyx

zurfyx commented Apr 18, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor 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 meta:main May 11, 2023
@Shubhankerism
Shubhankerism deleted the popup-menu-fix branch May 11, 2023 20:17
This was referenced May 23, 2023
GermanJablo pushed a commit to payloadcms/payload that referenced this pull request Jan 20, 2025
Fixes #10626

This was originally fixed in this [lexical
PR](meta/lexical#4301), however it seems
both the `TypeAheadMenu` plugin and the `TableActionMenu` plugin are
broken in lexical playground again.

I was unable to find any issues with the `SlashMenu` in our case so I
left it as is.

## Before


https://github.com/user-attachments/assets/5f8287a2-2875-4eb5-9402-933b0ce30af5

## After


https://github.com/user-attachments/assets/44394923-3dd8-4fd7-9d58-2c29886490e6
kendelljoseph pushed a commit to payloadcms/payload that referenced this pull request Feb 21, 2025
Fixes #10626

This was originally fixed in this [lexical
PR](meta/lexical#4301), however it seems
both the `TypeAheadMenu` plugin and the `TableActionMenu` plugin are
broken in lexical playground again.

I was unable to find any issues with the `SlashMenu` in our case so I
left it as is.

## Before


https://github.com/user-attachments/assets/5f8287a2-2875-4eb5-9402-933b0ce30af5

## After


https://github.com/user-attachments/assets/44394923-3dd8-4fd7-9d58-2c29886490e6

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 245d884e Deployed May 11, 2023 by vercel[bot]
Preview – lexical — 245d884e Deployed May 11, 2023 by vercel[bot]
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.

5 participants