-
Notifications
You must be signed in to change notification settings - Fork 95
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
Replace qtip JS library by a pure CSS tooltip #1324
Conversation
SonarCloud Quality Gate failed. 1 Bug No Coverage information |
@@ -65,8 +65,7 @@ | |||
"monolog/monolog": "1.23.*", | |||
"newerton/jquery-mousewheel": "dev-master", | |||
"pamelafox/lscache": "1.0.5", | |||
"malihu/malihu-custom-scrollbar-plugin": "3.1.5", | |||
"grimmlink/qtip2": "3.0.3" |
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.
Since this is a CSS only solution, we are only removing a JS dependency from composer.json
.
@@ -49,7 +49,7 @@ | |||
<a href="{% if request.vocabid and vocab.title%}{{ request.vocabid }}/{% endif %}{{ request.lang }}/feedback{% if request.contentLang and request.contentLang != request.lang %}?clang={{ request.contentLang }}{% endif %}{% if request.queryParam('anylang') == 'on' %}{% if request.contentLang == request.lang %}?{% else %}&{% endif %}anylang=on{% endif %}" id="navi3" class="navigation-font"> | |||
{% trans "Feedback" %} | |||
</a> | |||
<span id="navi4" tabindex="0" title="{% trans "helper_help" %}<br /><br />{% trans "search_example_text" %}"> | |||
<span class="skosmos-tooltip-wrapper skosmos-tooltip t-bottom" id="navi4" tabindex="0" data-title="{% trans "helper_help" %} 
 
 {% trans "search_example_text" %}"> |
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 title
attribute has the advantage that in non-JS sites it appears as a tooltip, handled by the browser. But qtip is disabling it after we initialize it.
In order to be JS-free, the only alternative is to use another attribute. We can use aria-* attributes, I think, in case we realize this option causes issues for users using screen readers, for example.
Codecov ReportBase: 71.17% // Head: 71.17% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #1324 +/- ##
=========================================
Coverage 71.17% 71.17%
Complexity 1650 1650
=========================================
Files 32 32
Lines 3788 3788
=========================================
Hits 2696 2696
Misses 1092 1092 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
I agree 100% that a pure CSS approach is preferable to a JS-based solution such as Popper. This PR looks like a big improvement. Some comments:
-
I think the animation (appearing from the top) is unnecessary and just adds to visual noise. As a metaphor it doesn't make sense to me - why would the popup window appear from the top? If anything, I think it should "emerge" from the spot where the cursor is pointed, like smoke that comes out from a chimney :) But just appearing out of nowhere, like with qtip2, would be best.
-
There's a little problem with the cross that is used to clear the contents of the search box - it will stay on top of the popup (probably need to adjust z-index?). I can't see the cross at all in your animation but here's how it looks to me (similar in both Firefox and Chrome):
-
There are other places in the UI where qtip2 is used, you need to address those as well obviously (as pointed out in a comment)
-
I think you also need to remove the following lines:
light.twig:<link href="resource/css/jquery.qtip.min.css" rel="stylesheet" type="text/css" />
scripts.twig:<script src="vendor/grimmlink/qtip2/dist/jquery.qtip.min.js"></script>
This PR is a bit old, I think it would be best to merge the changes from |
790987d
to
00923e6
Compare
Hi @osma, replies inline
Excellent!
Agreed. I actually prefer no animation if possible. Will change it.
Oh, doesn't look good. Let me see what I can do to improve it. Good catch! EDIT: Found it. You were correct about the z-index. The
Roger that 👍 I will update the other ones once we have fixed the feedback items above.
Ah! Yup. I left that because I didn't disable qtip in other places, I think. From what I remember, I left it enabled somewhere else and then opened two separate browser windows, to compare the generated CSS and how the UI behaved. This will be removed when I have finished the item above, of updating all the other UI elements that use qtip 👍 Thanks!! |
Looks like I'm wrong here. I actually removed the qtip from composer.json, so no reason for keeping these files. Let me remove them now. |
Note to self:
Example:
TODO: add note about what to do when the JS call specifies the location (just need to change the CSS classes…) |
I changed and tested I couldn't load AGROVOC to test reified properties. @osma would you have another smaller example dataset that I can load to test it, please? The reified icon is trickier, I just realized, as it displays not a text element, but instead a child div with other HTML elements. Gotta have to think more how to replace this one with pure css (still doable I think). Thanks |
Can you use the snippet from #1356 (comment) ? See the screenshots in the same comment for how it should look (but note that the display of that kind of partial SKOS XL data is a bit broken unless you also apply the changes in PR #1356) |
PR #1356 was just merged to |
0508ee7
to
e3c02a4
Compare
Rebased, and then modified my existing YSO data to have the prefix for skosxl and to have the property in the But now if I open skosmos-web | [Tue Sep 13 06:44:34.769517 2022] [php7:error] [pid 11] [client 172.19.0.1:41434] PHP Fatal error: Uncaught EasyRdf\\Http\\Exception: HTTP request for SPARQL query failed in /var/www/html/vendor/easyrdf/easyrdf/lib/Sparql/Client.php:247\nStack trace:\n#0 /var/www/html/vendor/easyrdf/easyrdf/lib/Sparql/Client.php(128): EasyRdf\\Sparql\\Client->request()\n#1 /var/www/html/model/sparql/GenericSparql.php(93): EasyRdf\\Sparql\\Client->query()\n#2 /var/www/html/model/sparql/GenericSparql.php(1475): GenericSparql->query()\n#3 /var/www/html/model/Concept.php(536): GenericSparql->queryLabel()\n#4 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1566): Concept->getProperties()\n#5 /tmp/skosmos-template-cache/ed/edd3a5fbdba4b947d8c145cd98bb65cab172eaea5513f6ffe050cafc75630ff2.php(400): twig_get_attribute()\n#6 /var/www/html/vendor/twig/twig/src/Template.php(405): __TwigTemplate_34d06a17ee23cf00128016f7cd55bc42f28d9e449367abf9e5f1bad707bb4a00->doDisplay()\n#7 /var/www/html/vendor/twig/twig/src/Template.php(378): Twig\\Template->displayWithErrorHandling()\n#8 /tmp/skosmos-template-cache/66/66e752b362c577ad7cde0210772fed34 in /var/www/html/view/concept-shared.twig on line 95 Do you know if I need to modify something else in my Skosmos installation to have skos-xl now? I can access other concepts just fine, it's just this one that's giving me the error. Thanks |
That looks like a SPARQL query failed. Can you do either/both of these:
|
7482287
to
dd59e5b
Compare
Rebased. |
… of white spaces.
Fixed! I used |
Huh, that's very interesting! There was a |
I checked that, and it's using the root css variable, set for Skosmos/resource/css/styles.css Lines 535 to 539 in 454f1d0
Would you like me to make just the reified tooltips a little smaller? Maybe Here's a preview where I didn't touch the CSS of the normal tooltip, used in the Help link, and where I reduced the reified tooltip text to 12px:
👍 Thanks! |
…e correctly rendered
Ah! Good spot, I accidentally removed spaces between css classes, so it was using |
I think this is the last pending item in your review, @osma. I will need a little more time to re-read it and understand how/what I should reproduce and test it. I think it's with the birches example I copied into my copy of YSO vocab, but it appears to be working correctly for me, but also not rendering like in your screenshots. Will leave this one to be fixed for over the next days 👋 Thanks! |
Thanks again @kinow! I made a new round of testing, this time without applying the Finto CSS layout in case it might interfer. It looks great now, pretty much all of my worries have been addressed. I could only find two quite minor and trivial things to change: Property name tooltipsThis is something I forgot to look at in detail in my previous review.
Display differences between reified definitions and SKOS XL labelsHere is a tooltip for a reified definition resource: Here is a similar tooltip for a SKOS XL label: They are very similar but not identical. The property name "Source:" is set in bold in the SKOS XL tooltip, but not the one for the definition. I like the bold version more, so could the tooltip for definitions (and similar resources) also use bold face for the property name? Other than these, I can't think of anything more that would need to be fixed before merging, so I think this is really, really close now! And already this is IMHO better than the current status quo because qtip2 seems to be a bit buggy (sometimes tooltip contents just disappear) and also there are some font and color issues with the old tooltips that this PR fixes as well 👍 |
Thanks a lot for testing it again and for the great feedback and screenshots @osma. I think we will have it ready for a final review and merge in the next iteration (i.e. next commits pushed soon). All your points sound doable, and not too hard 🙂 |
Replies inline Property name tooltips
Done! I also changed the alignment of the tooltip for Display differences between reified definitions and SKOS XL labels[x] They are very similar but not identical. The property name "Source:" is set in bold in the SKOS XL tooltip, but not the one for the definition. I like the bold version more, so could the tooltip for definitions (and similar resources) also use bold face for the property name? These are controlled in the template, not in the CSS style. I'm looking at the birches concept page. The tooltip of the Definition icon doesn't have bold anywhere. The tooltip of the Text In Other Languages does. That's controlled by having the After this screenshot, I re-read your comment, @osma, and after reading this part “also use bold face for the property name?”, so I moved the I also noticed that to reach the link sometimes the tooltip would disappear if the mouse cursor accidentally hovered outside the tooltip. I tweaked a bit the CSS classes and the location of the tooltip arrow, to see if that reduces the chances of the tooltip disappearing while the user moves it to click on the Source link. qtip could use JS to disappear with the tooltip after a few milliseconds, which gave some buffer for the user to move the mouse outside the element. We don't have that feature with CSS-only (a good trade-off I think, given that it reduces the JS dependencies and simplifies the code a bit IMO). The good news is that if there are other parts where the tooltip must adjust the text weight we should be able to do so without changing any or much of the tooltip CSS, and controlling that via the existing CSS classes and HTML structure. Let me know if this is looking better or if we need to further adjust it (feel free to commit directly if you'd like, I can sync the branch and post a preview screenshot here too). So ready again for review whenever you have time @osma! Thanks 👍 Cheers, |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Thanks @kinow ! Everything was good except I wasn't 100% happy with the way properties and values were displayed - which was inconsistent from the beginning so no fault in this PR really). I made a few more tweaks in a commit that I just pushed to your PR branch. I will merge this now 🎉 |
Thanks @osma! |
A rather strange artifact that looks like an empty tooltip box has appeared to dev.finto.fi where we are testing the new skosmos version. This appears when mouse is hovered over "Hierarchy" tab while any of the other tabs are active. See for example: https://dev.finto.fi/yso/en/ According to @osma this might be related to this PR, any ideas about the cause and possible fix Osma and @kinow ? |
Ah, I loved the description 😄 That's the tooltip for the Hierarchy tab option I think. The rotated (45 degree?) square is the "triangle" or "arrow" that sticks out of the tooltip. The black/darker part is the actual tooltip, but it appears to be completely empty. Causing it to look strange that way.
That's really odd. I couldn't see anything wrong from a quick inspection with the browser. The top menu “Help” option has a tooltip too, and that one appears to be working fine. Let me check the templates to see if there's anything that could break it, and if I cannot find it I will try to reproduce it locally. Thanks @MikkoAleksanteri |
Alright, looking at the template file |
Thank you @kinow for the quick response and fix! |
Reasons for creating this PR
Replace the deprecated qtip JS library by a pure CSS tooltip.
Link to relevant issue(s), if any
Description of the changes in this PR
In #1151, when I looked at the qtip library alternatives, the first that I thought about was using Bootstrap's popover component. That requires us including and loading the Popper.js library.
My idea was to add this new dependency, import before
docready.js
, and initialize the instances for each object. Similar to what we are doing with qtip. Finally, I would also have to spend some time customizing the CSS to match qtip's output.However, I thought perhaps we could try a solution without JavaScript first. This way in the future we won't have to worry about tooltips, replacing libraries, updating popper, etc.
Known problems or uncertainties in this PR
I used the example from this post: https://dev.to/r3zu3/pure-css-tooltip-1k3j. The author uses it in his library z.css, licensed under the Apache License.
We need to customize the time of the animation, and the location of the tooltip.
I also have implemented only the "Help" text tooltip. I am not sure if we are not using any other features of qtip in other parts of the UI.
Checklist