Skip to content

Commit e7e72d2

Browse files
committed
Disable download svg button when editing text labels
1 parent 61558b4 commit e7e72d2

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

js/widgets/main_plot.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,13 @@ $(function() {
712712
a.dispatchEvent(e)
713713
},
714714

715+
toggle_svg_button: function() {
716+
let disable = this._elements.main_plot.selectAll("foreignObject").size() > 0;
717+
d3.select("#download-svg-button")
718+
.property("disabled", disable)
719+
.attr("title", disable ? "Cannot download SVG while labels are being edited" : null)
720+
},
721+
715722
export: function() {
716723
return {title: this.title, xlabel: this.xlabel, ylabel: this.ylabel, opacity: this.opacity,
717724
smoothing: this.smoothing, bp_shift: this.bp_shift, xmin: this.xmin, xmax: this.xmax,
@@ -838,7 +845,10 @@ $(function() {
838845

839846
this.foreign_object.select("input")
840847
.on("keypress", function(e) {$(label_group.node()).editable_svg_text("enter_input", e)})
841-
.node().focus()
848+
.attr("title", "Press enter to submit")
849+
.node().focus();
850+
851+
$("#main-plot").main_plot("toggle_svg_button")
842852
},
843853

844854
enter_input: function(ev) {
@@ -849,7 +859,9 @@ $(function() {
849859
this.change_label(ev.target.value)
850860
} else {
851861
this.text_label.style("display", null)
852-
}
862+
};
863+
864+
$("#main-plot").main_plot("toggle_svg_button")
853865
}
854866
},
855867

0 commit comments

Comments
 (0)