-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 dynamic content loading init problem #33748
Conversation
3f1a0ea
to
3644e2a
Compare
3644e2a
to
62a9254
Compare
Not too many changes by ignoring spaces: https://github.com/go-gitea/gitea/pull/33748/files?diff=unified&w=1 |
@@ -0,0 +1,89 @@ | |||
import {isDocumentFragmentOrElementNode} from '../utils/dom.ts'; | |||
|
|||
type DirElement = HTMLInputElement | HTMLTextAreaElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's supposed to be direction
, not directory
.
I was confused for a second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next: Refactor global init code and add more comments #33755 |
* giteaofficial/main: Use pullrequestlist instead of []*pullrequest (go-gitea#33765) Upgrade act to 0.261.4 and actions-proto-go to v0.4.1 (go-gitea#33760) Webhook add X-Gitea-Hook-Installation-Target-Type Header (go-gitea#33752) Fix dynamic content loading init problem (go-gitea#33748) [skip ci] Updated translations via Crowdin Add composor source field (go-gitea#33502) upgrade go-crypto from 1.1.5 to 1.1.6 (go-gitea#33745) Disable go license generation as part of `make tidy` (go-gitea#33747) Refactor repo-diff.ts (go-gitea#33746) Use `git diff-tree` for `DiffFileTree` on diff pages (go-gitea#33514) [skip ci] Updated translations via Crowdin Improve "generate new access token" form (go-gitea#33730) Remove superflous tw-content-center (go-gitea#33741) Clone repository with Tea CLI (go-gitea#33725) allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam (go-gitea#33684) Show info about maintainers are allowed to edit a PR (go-gitea#33738) Improve admin user view page (go-gitea#33735) [skip ci] Updated translations via Crowdin Align sidebar gears to the right (go-gitea#33721)
Follow up go-gitea#33748 Now there are 3 "global" functions: * registerGlobalSelectorFunc: for all elements matching the selector, eg: `.ui.dropdown` * registerGlobalInitFunc: for `data-global-init="initInputAutoFocusEnd"` * registerGlobalEventFunc: for `data-global-click="onCommentReactionButtonClick"` And introduce `initGlobalInput` to replace old `initAutoFocusEnd` and `attachDirAuto`, use `data-global-init` to replace fragile `.js-autofocus-end` selector. Another benefit is that by the new approach, no matter how many times `registerGlobalInitFunc` is called, we only need to do one "querySelectorAll" in the last step, it could slightly improve the performance.
dirauto.ts
toobserver.ts
.observeAddedElement
to init all non-custom "dropdown".data-global-click
to handle click events from dynamically loaded elements..comment-reaction-button
) mechanism is removed..diff-box
selector, it was abused and never really used.A lot of FIXMEs in "repo-diff.ts" are completely fixed, newly loaded contents could work as expected.
data-global-init
code is almost ready, if further readers, when need to use it, add a "registerGlobalInitFunc" then it should work.