-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix elipsis button not working if the last commit loading is deferred #29544
Conversation
Before this change, if we had more than 200 entries being deferred in loading, the entire table would get replaced thus losing any event listeners attached to the elements within the table, such as the elipsis button and commit list with tippy. With this change we remove the previous javascript code that replaced the table and use htmx to replace the table. htmx attributes added: - `hx-indicator="tr.notready td.message span"`: attach the loading spinner to the files whose last commit is still being loaded - `hx-trigger="load[this.querySelectorAll('tr.notready').length > 0]"` trigger the request-replace behavior as soon as possible and only if the current table is showing files that haven't had their latest commit info loaded. If this inline javascript doesn't look good I can change it so the backend doesn't render the htmx attributes if it's an htmx request, and the trigger would simply be `load` but I like it as it is now - `hx-swap="morph"`: use the idiomorph morphing algorithm, this is the thing that makes it so the elipsis button event listener is kept during the replacement, fixing the bug - `hx-post="{{.LastCommitLoaderURL}}"`: make a post request to this url to get the table with all of the commit information As part of this change I removed the handling of partial replacement in the case we have less than 200 "not ready" files. The first reason is that I couldn't make htmx replace only a subset of returned elements, the second reason is that we have a cache implemented in the backend already so the only cost added is that we query the cache a few times (which is sure to be populated due to the initial request), and the last reason is that since the last refactor of this functionality that removed jQuery we don't properly send the "not ready" entries as the backend expects `FormData` with `f[]` and we send a JSON with `f` so we always query for all rows anyway. Signed-off-by: Yarden Shoham <git@yardenshoham.com>
cc @delvh because of #29230 (comment) |
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
ps: does it really fixe "elipsis button not working if the last commit loading is deferred"? I think it is a longstanding problem, because since the code before #29230, initRepoEllipsisButton is not really called if the last commit loading is deferred? |
It fixes the bug as you can see in the GIF. Also, yes this bug existed before #29230. See #29230 (comment) |
Which line/block of code of this PR fixes "elipsis button not working if the last commit loading is deferred" ? I don't see when/where the initRepoEllipsisButton is called differently. |
|
This comment was marked as off-topic.
This comment was marked as off-topic.
I guess it is a longstanding problem and is not in this PR's scope. I am just curious about the details. So feel free to ignore these comments. |
I understand you now, using After this PR gets merged I see 2 ways forward:
I can send a PR with |
After more thoughts, I guess we could just do nothing. By reading the code, I think maybe the "LatestCommit" couldn't be nil .... if I understand correctly, GetCommitsInfo always returns LatestCommit
So I'd like to keep it simple, until some problems really happen one day ....... |
Agreed |
Remove the "..." from the loading states? One indicator is enough imho. |
* upstream/main: Breaking summary for template refactoring (go-gitea#29395) [skip ci] Updated translations via Crowdin Fix incorrect cookie path for AppSubURL (go-gitea#29534) gitea.service: Remove syslog.target (go-gitea#29550) Add option to set language in admin user view (go-gitea#28449) Fix elipsis button not working if the last commit loading is deferred (go-gitea#29544) Fix incorrect relative/absolute URL usages (go-gitea#29531) Add support for API blob upload of release attachments (go-gitea#29507) Fix queue worker incorrectly stopped when there are still more items in the queue (go-gitea#29532) remove util.OptionalBool and related functions (go-gitea#29513) Rename Action.GetDisplayName to GetActDisplayName (go-gitea#29540) Make PR form use toast to show error message (go-gitea#29545)
Before this change, if we had more than 200 entries being deferred in loading, the entire table would get replaced thus losing any event listeners attached to the elements within the table, such as the elipsis button and commit list with tippy.
With this change we remove the previous javascript code that replaced the table and use htmx to replace the table.
htmx attributes added:
hx-indicator="tr.notready td.message span"
: attach the loading spinner to the files whose last commit is still being loadedhx-trigger="load"
trigger the request-replace behavior as soon as possiblehx-swap="morph"
: use the idiomorph morphing algorithm, this is the thing that makes it so the elipsis button event listener is kept during the replacement, fixing the bug because we don't actually replace the table, only modifying ithx-post="{{.LastCommitLoaderURL}}"
: make a post request to this url to get the table with all of the commit informationAs part of this change I removed the handling of partial replacement in the case we have less than 200 "not ready" files. The first reason is that I couldn't make htmx replace only a subset of returned elements, the second reason is that we have a cache implemented in the backend already so the only cost added is that we query the cache a few times (which is sure to be populated due to the initial request), and the last reason is that since the last refactor of this functionality that removed jQuery we don't properly send the "not ready" entries as the backend expects
FormData
withf[]
and we send a JSON withf
so we always query for all rows anyway.Before
After