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

DEV: allows for multiple menus/tooltips #26823

Merged
merged 9 commits into from May 7, 2024

Conversation

jjaffeux
Copy link
Contributor

@jjaffeux jjaffeux commented Apr 30, 2024

menus and tooltips are now appended to their own portals. The service are the only responsible for managing the instances, prior to this commit, services could manage one instance, but the DMenu and DTooltip components could also take over which could cause unexpected states.

This change also allows nested menus/tooltips.

Other notable changes:

  • few months ago core copied the CloseOnClickOutside modifier of float-kit without removing the float-kit one, this commit now only use the core one.
  • the close function is now trully async
  • the close function accepts an instance or an identifier as parameter

@github-actions github-actions bot added the chat PRs which include a change to Chat plugin label Apr 30, 2024
@jjaffeux jjaffeux force-pushed the member-xp/multiple-menus-tooltips branch 2 times, most recently from 43ea1f3 to 41b4df0 Compare May 3, 2024 16:22
menus and tooltips are now appended to their own portals. The service are the only responsible for managing the instances, prior to this commit, services could manage one instance, but the DMenu and DTooltip components could also take over which could cause unexpected states.

This change also allows nested menus/tooltips.

Other notable changes:

few months ago core copied the CloseOnClickOutside modifier of float-kit without removing the float-kit one, this commit now only use the core one.
the close function is now trully async
the close function accepts an instance or an identifier as parameter
@jjaffeux jjaffeux force-pushed the member-xp/multiple-menus-tooltips branch from 41b4df0 to 702c053 Compare May 7, 2024 16:04
@tracked tooltipInstance = null;
registerTrigger = modifier((element) => {
if (!this.tooltipInstance?.trigger) {
next(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What breaks without this next()? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The world.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More seriously I had exceptions in tests I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@CvX here is the exact error without the next:

global failure: Error: Assertion Failed: You attempted to update _trigger on DTooltipInstance, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will merge with the next for now, but open to a better solution if you know one

app/assets/javascripts/float-kit/addon/services/menu.js Outdated Show resolved Hide resolved
@jjaffeux jjaffeux merged commit fe16633 into discourse:main May 7, 2024
16 checks passed
@jjaffeux jjaffeux deleted the member-xp/multiple-menus-tooltips branch May 7, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat PRs which include a change to Chat plugin
2 participants