-
-
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
Use a general approach to show tooltip, fix temporary tooltip bug #23574
Conversation
6f2622e
to
d06b47c
Compare
One change I was planning to to is to remove the I certainly can't approve two ways to init tooltips like this PR does via coexistance of |
It would be too much. Could we just have this one, and do the replacing |
gitea/docs/content/doc/developers/guidelines-refactoring.en-us.md Lines 31 to 51 in dbdb5ba
|
Please just use
I don't know about others but I generally can't accept suboptimal "intermediate" solutions. Just go all the way please. |
I do like
If you do not have strong objection, I will ask other maintainers' opinions. |
I don't know but I think I've personally had enough of your "temporary" solutions. I want robust, simple and easy to maintain solutions, not such a mess like the getComputedStyle when toggling a class. |
I do not know what do you mean. I have done a lot of refactorings, all of them are stable. And I have used my solutions (which you don't like, for example, catch frontend bugs, improve async calls, use For the I always finish my promises, to make the refactorings clear and stable. You can check:
I do not understand what you mean by "mess". If you say mess, the Gitea frontend (before I joint) was totally a mess. |
web_src/js/modules/tippy.js
Outdated
if (mutation.type === 'childList') { | ||
for (const el of mutation.addedNodes) { | ||
// handle all "tooltip" elements in newly added nodes, skip non-related nodes (eg: "#text") | ||
if (el.querySelectorAll) { |
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.
this line looks broken.
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.
Not broken, just a quick check to see the "node" has querySelectorAll
function, which is needed by attachChildrenLazyTippyTooltip
below.
Otherwise some nodes (like #text
) couldn't be used to attach tippy.
I agree that there would be other approaches to check if the node is non-#text, at the moment, this quick check is clear and fast IMO.
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.
Use node.nodeType please, it's much more clear.
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.
Can you provide a list for the types?
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.
Should be [Node.ELEMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE].includes(el.nodeType)
.
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.
But that's slower than the if (el.querySelectorAll)
check. Do you really want to do so?
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.
Alternatively 'querySelectorAll' in el
would also make the indent clear enough for me.
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.
OK, then 'querySelectorAll' in el
: ba8ad89
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.
Ok
I can accept a few of these changes here but the duality of |
|
According the comment below that line, the |
3f6eb42
to
3e195a2
Compare
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #23574 +/- ##
==========================================
+ Coverage 47.14% 47.16% +0.01%
==========================================
Files 1149 1154 +5
Lines 151446 152353 +907
==========================================
+ Hits 71397 71854 +457
- Misses 71611 72014 +403
- Partials 8438 8485 +47
... and 34 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
# Conflicts: # web_src/js/index.js
There are still many new PRs still using To explain why (with details): If I also refactor To make things clear, in next PR, we "only" rename the Please follow #23649 after this gets merged. |
Let's move to #23649 , it's big enough for reviewing. |
* upstream/main: Fix incorrect `HookEventType` of pull request review comments (go-gitea#23650) [skip ci] Updated translations via Crowdin Fix codeblocks in the cheat sheet (go-gitea#23664) Drop migration for ForeignReference (go-gitea#23605) Fix new issue/pull request btn margin when it is next to sort (go-gitea#23647) A tool to help to backport locales, changes source strings to fix other broken translations (go-gitea#23633) Fix incorrect `show-modal` and `show-panel` class (go-gitea#23660) Restructure documentation. Now the documentation has installation, administration, usage, development, contributing the 5 main parts (go-gitea#23629) Check LFS/Packages settings in dump and doctor command (go-gitea#23631) Use a general approach to show tooltip, fix temporary tooltip bug (go-gitea#23574) Improve workflow event triggers (go-gitea#23613) Improve `<SvgIcon>` to make it output `svg` node and optimize performance (go-gitea#23570)
Follow: * #23574 * Remove all ".tooltip[data-content=...]" Major changes: * Remove "tooltip" class, use "[data-tooltip-content=...]" instead of ".tooltip[data-content=...]" * Remove legacy `data-position`, it's dead code since last Fomantic Tooltip -> Tippy Tooltip refactoring * Rename reaction attribute from `data-content` to `data-reaction-content` * Add comments for some `data-content`: `{{/* used by the form */}}` * Remove empty "ui" class * Use "text color" for SVG icons (a few)
TLDR
initTooltip
again and again.Details
The performance
Creating a lot of tippy tooltip instances is expensive. This PR doesn't create all tippy tooltip instances, instead, it only adds "mouseover" event listener to necessary elements, and then switches to the tippy tooltip
The general approach for all tooltips
Before, dynamically generated tooltips need to be called with
initTooltip
.After, use MutationObserver to:
It does help a lot, eg:
gitea/web_src/js/components/PullRequestMergeForm.vue
Lines 33 to 36 in 1a4efa0
Temporary tooltip re-entrance bug
To reproduce, on try.gitea.io, click the "copy clone url" quickly, then the tooltip will be "Copied!" forever.
After this PR, with the help of
attachTippyTooltip
, the tooltip content could be reset to the default correctly.Other changes
data-tooltip-content
is preferred from now on, the olddata-content
may cause conflicts with other modules.data-placement
was only used for tooltip, so it's renamed todata-tooltip-placement
, and removed fromcreateTippy
.