Skip to content

Commit

Permalink
fix: Add class to tooltip DOM element distinguish errors from warnings (
Browse files Browse the repository at this point in the history
#4810)

* Add class to tooltip DOM element distinguish errors from warnings

* Move ClassName to constant + handle undefined / null annotation ClassName
  • Loading branch information
BenSouchet authored May 31, 2022
1 parent 57ded09 commit d2446d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/ace/mouse/default_gutter_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ function GutterHandler(mouseHandler) {
tooltipAnnotation = annotation.text.join("<br/>");

tooltip.setHtml(tooltipAnnotation);

var annotationClassName = annotation.className;
if (annotationClassName) {
tooltip.setClassName(annotationClassName.trim());
}

tooltip.show();
editor._signal("showGutterTooltip", tooltip);
editor.on("mousewheel", hideTooltip);
Expand Down
5 changes: 4 additions & 1 deletion lib/ace/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ define(function(require, exports, module) {
var oop = require("./lib/oop");
var dom = require("./lib/dom");

var CLASSNAME = "ace_tooltip";

/**
* @class Tooltip
**/
Expand All @@ -52,7 +54,7 @@ function Tooltip (parentNode) {
(function() {
this.$init = function() {
this.$element = dom.createElement("div");
this.$element.className = "ace_tooltip";
this.$element.className = CLASSNAME;
this.$element.style.display = "none";
this.$parentNode.appendChild(this.$element);
return this.$element;
Expand Down Expand Up @@ -114,6 +116,7 @@ function Tooltip (parentNode) {
this.hide = function() {
if (this.isOpen) {
this.getElement().style.display = "none";
this.getElement().className = CLASSNAME;
this.isOpen = false;
}
};
Expand Down

0 comments on commit d2446d6

Please sign in to comment.