-
-
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
Extend jQuery with customized show/hide/toggle #22884
Conversation
7e62981
to
309d8bf
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 #22884 +/- ##
=======================================
Coverage ? 47.32%
=======================================
Files ? 1113
Lines ? 150188
Branches ? 0
=======================================
Hits ? 71076
Misses ? 70668
Partials ? 8444 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
||
&.hide-outdated { | ||
display: none !important; | ||
} |
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.
The most hacky part has been removed.
@@ -57,7 +57,6 @@ | |||
.show-outdated, | |||
.hide-outdated { | |||
&:extend(.unselectable); | |||
display: block !important; |
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.
Another hacky part, it is also removed.
Assuming we want to eventually get rid of jQuery, I would oppose to extending it. Instead I would use simple helper functions that works with both plain function show(els) {
if (els instanceof Node) {
els.classList.remove('gt-hidden');
} else if (els instanceof NodeList) {
for (const el of els) {
els.classList.remove('gt-hidden');
}
} else if (els instanceof $) {
els.each(el, function() {
this.classList.remove("gt-hidden");
});
}
}
function hide(els) {
if (els instanceof Node) {
els.classList.add('gt-hidden');
} else if (els instanceof NodeList) {
for (const el of els) {
els.classList.add('gt-hidden');
}
} else if (els instanceof $) {
els.each(el, function() {
this.classList.add("gt-hidden");
});
}
} This will allow enabling the |
This is the first step, to avoid breaking anything. You can fine tune anything after the code gets refactored correctly. |
What do you think about the |
|
If you want to skip this step (customize the jQuery's show/hide), then the next PR must do all the following things at the same time:
In my mind, "Replace all jQuery.show()/jQuery.hide() to the new show()/hide()" is the biggest change, it will change a lot of lines/logic and it may need more time. So this PR just makes jQuery works with With this step, all code then can start using |
@silverwind if you still prefer to not touch the jQuery, the separate PR is |
I'd argue these should be refactored to have the hidden class initially in HTML.
It does appear writing to |
Of course, you could argue. If you have checked every CSS style to guarantee that there is no such usage anymore, then you do not need that BUT, if you haven't checked, to make sure nothing would be broken, you absolutely need that Could you check everything and give me a feed back? Update: you could take a look at #22916 first, it only contains the
I know you prefer. I have explained my plain in #22847 , the "Solution": Drop all other classes/attributes, only use the .gt-hidden to hide |
A separate PR from #22884 (without touching the jQuery methods)
Replaced by #22950 |
Follow
gt-
#22879This PR makes jQuery works well in all cases, it is the first step for
About jQuery
jQuery's
show/hide/toggle
doesn't work with ourgt-hidden
class which has!important
.gt-hidden { display: none !important; }
because of the!important
.!important
is necessary for many cases. eg: overwrite the otherdisplay: flex
Ref: jQuery's show/hide: https://github.com/jquery/jquery/blob/main/src/css/showHide.js
Some more info:
.hide.show-outdate
and.hide.hide-outdated
) has been cleaned up.hide
class.Screenshot (the refactored show/hide buttons work well):
The
show
buttonSwitch to the
hide
button and show details