-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add class to tooltip DOM element distinguish errors from warnings #4810
Add class to tooltip DOM element distinguish errors from warnings #4810
Conversation
The |
Codecov Report
@@ Coverage Diff @@
## master #4810 +/- ##
==========================================
+ Coverage 71.12% 71.16% +0.04%
==========================================
Files 554 554
Lines 55711 55716 +5
Branches 10419 10420 +1
==========================================
+ Hits 39623 39651 +28
+ Misses 16088 16065 -23
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review 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.
Thanks for the PR! Left some comments, but please also add a test for this functionality
@@ -114,6 +114,7 @@ function Tooltip (parentNode) { | |||
this.hide = function() { | |||
if (this.isOpen) { | |||
this.getElement().style.display = "none"; |
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.
You can store this class name in some constant / property so in cass it’s changed we change it in one place
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 have created a constant var CLASSNAME
@@ -87,6 +87,7 @@ function GutterHandler(mouseHandler) { | |||
tooltipAnnotation = annotation.text.join("<br/>"); | |||
|
|||
tooltip.setHtml(tooltipAnnotation); | |||
tooltip.setClassName(annotation.className.trim()); |
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.
It might happen that className is undefined or null when annotation type is custom for example, so we should account for this too
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 added an if statement to ensure we don't call .trim()
and setClassName()
with an undefined
or null
value
Last point it seems there isn't any test for the Maybe this merge request isn't the best place for the creation and writing of all the tests of the (I think I can manage to add one test to an existing test file but create the whole file with the setup/init process It's would be too difficult for me 🙁 ) |
@BenSouchet sure, no worries about the test, I really thought we had one for tooltip already |
Merged, thanks for contribution! |
Issue #4799 Styling Tooltip Base on Gutter Annotation Type
Description of changes:
Adding required lines to add a CSS class to the tooltip element to distinguish errors from warnings.
Test by building ace from my branch, it's working like a charm:
Not sure about if it the proper way to reset the
className
with an hardcoded value tho'