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

Support host and ref options in Menu.open #700

Merged
merged 2 commits into from May 19, 2024

Conversation

ianthomas23
Copy link
Contributor

Implements enhancement #699.

This exposes the Widget.attach optional arguments host and ref in Menu.IOptions to provide greater control over exactly where in the DOM the menu div is attached.

I have kept the names and descriptions of the options the same as in Widget.attach.

Copy link

welcome bot commented Apr 26, 2024

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

forceY: boolean
forceY: boolean,
host: HTMLElement | null,
ref: HTMLElement | null
): void {
// Get the current position and size of the main viewport.
const windowData = getWindowData();
Copy link
Member

Choose a reason for hiding this comment

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

With the proposed changes the menu could end up beyond the boundaries of the element. This will be potentially problematic if the parent element (host) has clips the menu off. Is my thinking correct?

I think this is fine to merge as-is, I just wonder if this should be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, your thinking is correct. But it isn't a result of these changes, it was always possible for the menu to be outside of the host element. That is essentially what the ipydatagrid problem using voila was, the menu was appearing outside of the body, which I didn't think was even possible but it is correct following the rules of CSS absolute positioning.

I will add a note about this.

@krassowski
Copy link
Member

You will need to run yarn run api and commit changes.

@krassowski krassowski added the enhancement New feature or request label Apr 26, 2024
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @ianthomas23

FYI (not requiring code changes) it is better to used the non nullish operator ?? rather than the or operator.
The reason or is used a lot in lumino is that the code predates the introduction of that operator.

The goal is to avoid the case of a falsy value being overridden by the default like 0 || 1 != 0 ?? 1 (the first equals one when the second equals 0).

@fcollonval
Copy link
Member

in addition to the API update, you will need to lint the code with yarn lint. One of the tests is failing due to

[warn] packages/widgets/tests/src/menu.spec.ts

@ianthomas23
Copy link
Contributor Author

Thanks for the guidance @krassowski and @fcollonval. I've added the extra documentation to Menu.open, although it could possibly be added to IOpenOptions instead, as that was my entry point into the docs. I've also switched the || to ?? in the new code whilst I was there.

@ianthomas23
Copy link
Contributor Author

I cannot tell if the failing macos-latest webkit-headless CI run is something that I have caused or if it is unrelated.

@fcollonval
Copy link
Member

I cannot tell if the failing macos-latest webkit-headless CI run is something that I have caused or if it is unrelated.

This is due to flakiness - I let @krassowski have a second look.

@fcollonval
Copy link
Member

gentle ping to @krassowski

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Thanks!

@fcollonval fcollonval merged commit f26c85a into jupyterlab:main May 19, 2024
16 of 17 checks passed
Copy link

welcome bot commented May 19, 2024

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@ianthomas23 ianthomas23 deleted the 699_menu_open_host_ref branch May 19, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants