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

Only conditionally render most of content action dropdown and workaround for tippy warning #2422

Merged
merged 7 commits into from
Apr 13, 2024

Conversation

matc-pub
Copy link
Collaborator

This only starts rendering the dropdown and each modal dialog when they are shown for first time. For simplicity they keep getting rendered until the component unmounts.

A small fix when the Modal promise resolves after the component umounts. I don't remember how to trigger this, but saw this occasionally happen.

Also a work around for the tippy warning. Turns out tippy doesn't remove all event listeners when it destroys an instance.

Tippy doesn't remove its onDocumentPress listener when destroyed.
Instead the listener removes itself after calling hide for hideOnClick.

It doesn't look like there is a way to reliable work around this.

This skips the warning for the first hide call on a destroyed tippy
instance.

Cleanup is only performed after at least ten tippy instances have been
created.
Modals use `await import("bootstrap/js/dist/modal")` when being mounted.
This means its possible that the component unmounts before the promise
resolves.
@@ -174,292 +188,305 @@ export default class ContentActionDropdown extends Component<
aria-expanded="false"
aria-controls={dropdownId}
aria-label={I18NextService.i18n.t("more")}
onClick={() => this.setState({ dropdownOpenedOnce: true })}
Copy link
Member

@SleeplessOne1917 SleeplessOne1917 Apr 12, 2024

Choose a reason for hiding this comment

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

Should use linkEvent with this. This will also involve creating a function that takes the ContentActionDropdown as an arg and calls setState on it.

@SleeplessOne1917
Copy link
Member

I noticed that the dynamic import and setup/cleanup gets repeated everywhere we use the modal. Do you think mixins similar to what you did in the previous PR could alleviate this?

@SleeplessOne1917 SleeplessOne1917 merged commit fdeb924 into LemmyNet:main Apr 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants