Skip to content

Comments on dynamically added content do not work #33532

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

Closed
McRaeAlex opened this issue Feb 7, 2025 · 3 comments
Closed

Comments on dynamically added content do not work #33532

McRaeAlex opened this issue Feb 7, 2025 · 3 comments
Assignees
Labels
topic/ui Change the appearance of the Gitea UI type/bug

Comments

@McRaeAlex
Copy link
Contributor

McRaeAlex commented Feb 7, 2025

Description

When content is dynamically added to the page and comments that are part of the dynamically added content do not have "full" behaviour.

For example when viewing a pull request which doesn't have all the files loaded (exceeds git.MAX_GIT_DIFF_FILES) then a "Show More" button appears at the bottom of the page. When the new file diffs are loaded they include their comments however the user isn't able to edit them.

To reproduce I suggest creating a design review with 2 files, adding a comment on the second and then setting git.MAX_GIT_DIFF_FILES=1 and reloading. This will force you to click "show more" and observe the behaviour when trying to edit the comment.

Problem

The event listener isn't being attached to the DOM for the the button. The eventHandler can be found at semantic.js:2391 (of the build output). I am working on figuring out where the event listener should be added but any help would be apprieciated.

Screenshots

Button thats not working

Image

Screen Recording

Screen.Recording.2025-02-07.at.12.23.13.PM.mov

Gitea Version

main, 1.23, 1.22

Can you reproduce the bug on the Gitea demo site?

Yes but due to git.MAX_GIT_DIFF_FILES being rather large its easier to do locally.

Operating System

No response

Browser Version

Chrome, Firefox latest

@McRaeAlex McRaeAlex added topic/ui Change the appearance of the Gitea UI type/bug labels Feb 7, 2025
@McRaeAlex McRaeAlex changed the title Comments on dynamically added content do not work. Comments on dynamically added content do not work Feb 7, 2025
@McRaeAlex
Copy link
Contributor Author

I am working on this as it comes up for some customers. I will post any updates here. If anyone has insights please let me know.

@McRaeAlex
Copy link
Contributor Author

After looking at this a bit, it seems this event listener is added in initGlobalDropdown which only runs once when the DOM is loaded.

Its unclear to if calling initGlobalDropdown again on every "Show More" is suitable. It seems like a heavy handed approach and may result in multiple event listeners.

I am looking for something similar to htmx.process but for the fomantic stuff.

@wxiaoguang
Copy link
Contributor

Thank you for the report&investigation and the PR.

I think it could be closed (fixed by Fix dynamic content loading init problem #33748 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants