Skip to content

Commit 9183ef9

Browse files
authored
Merge pull request #5993 from plotly/firefox82-overflow-visible
Temporary fix to help improve rendering of graphs with Mathjax on Firefox v82 and higher
2 parents 052929c + e75ea19 commit 9183ef9

File tree

6 files changed

+71
-10
lines changed

6 files changed

+71
-10
lines changed

Diff for: .circleci/config.yml

+43
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,43 @@ jobs:
163163
name: Test MathJax on firefox-81
164164
command: .circleci/test.sh mathjax-firefox
165165

166+
mathjax-firefox82:
167+
docker:
168+
# need '-browsers' version to test in real (xvfb-wrapped) browsers
169+
- image: cimg/node:16.8.0-browsers
170+
environment:
171+
# Alaska time (arbitrary timezone to test date logic)
172+
TZ: "America/Anchorage"
173+
working_directory: ~/plotly.js
174+
steps:
175+
- browser-tools/install-browser-tools: &browser-versions
176+
firefox-version: '82.0'
177+
install-chrome: false
178+
install-chromedriver: false
179+
- attach_workspace:
180+
at: ~/
181+
- run:
182+
name: Test MathJax on firefox-82
183+
command: .circleci/test.sh mathjax-firefox82+
184+
185+
mathjax-firefoxLatest:
186+
docker:
187+
# need '-browsers' version to test in real (xvfb-wrapped) browsers
188+
- image: cimg/node:16.8.0-browsers
189+
environment:
190+
# Alaska time (arbitrary timezone to test date logic)
191+
TZ: "America/Anchorage"
192+
working_directory: ~/plotly.js
193+
steps:
194+
- browser-tools/install-browser-tools: &browser-versions
195+
install-chrome: false
196+
install-chromedriver: false
197+
- attach_workspace:
198+
at: ~/
199+
- run:
200+
name: Test MathJax on firefox-latest
201+
command: .circleci/test.sh mathjax-firefox82+
202+
166203
make-baselines:
167204
parallelism: 4
168205
docker:
@@ -343,6 +380,12 @@ workflows:
343380
- mathjax-firefox81:
344381
requires:
345382
- install-and-cibuild
383+
- mathjax-firefox82:
384+
requires:
385+
- install-and-cibuild
386+
- mathjax-firefoxLatest:
387+
requires:
388+
- install-and-cibuild
346389
- no-gl-jasmine:
347390
requires:
348391
- install-and-cibuild

Diff for: .circleci/test.sh

+5
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ case $1 in
7474
exit $EXIT_STATE
7575
;;
7676

77+
mathjax-firefox82+)
78+
./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --FF --skip-tags=noFF82 --bundleTest=mathjax --nowatch || EXIT_STATE=$?
79+
exit $EXIT_STATE
80+
;;
81+
7782
make-baselines)
7883
SUITE=$(find $ROOT/test/image/mocks/ -type f -printf "%f\n" | sed 's/\.json$//1' | circleci tests split)
7984
python3 test/image/make_baseline.py $SUITE || EXIT_STATE=$?

Diff for: draftlogs/5993_fix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Temporary fix to improve rendering of graphs with Mathjax on Firefox v82 and higher [[#5993](https://github.com/plotly/plotly.js/pull/5993)]

Diff for: src/lib/svg_text_utils.js

+20-8
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ exports.convertToTspans = function(_context, gd, _callback) {
9494
newSvg.node().firstChild);
9595
}
9696

97+
var w0 = _svgBBox.width;
98+
var h0 = _svgBBox.height;
99+
97100
newSvg.attr({
98101
'class': svgClass,
99-
height: _svgBBox.height,
102+
height: h0,
100103
preserveAspectRatio: 'xMinYMin meet'
101104
})
102105
.style({overflow: 'visible', 'pointer-events': 'none'});
@@ -105,9 +108,18 @@ exports.convertToTspans = function(_context, gd, _callback) {
105108
var g = newSvg.select('g');
106109
g.attr({fill: fill, stroke: fill});
107110

108-
var gBB = g.node().getBoundingClientRect();
109-
var newSvgW = gBB.width;
110-
var newSvgH = gBB.height;
111+
var bb = g.node().getBoundingClientRect();
112+
var w = bb.width;
113+
var h = bb.height;
114+
115+
if(w > w0 || h > h0) {
116+
// this happen in firefox v82+ | see https://bugzilla.mozilla.org/show_bug.cgi?id=1709251 addressed
117+
// temporary fix:
118+
newSvg.style('overflow', 'hidden');
119+
bb = newSvg.node().getBoundingClientRect();
120+
w = bb.width;
121+
h = bb.height;
122+
}
111123

112124
var x = +_context.attr('x');
113125
var y = +_context.attr('y');
@@ -119,21 +131,21 @@ exports.convertToTspans = function(_context, gd, _callback) {
119131
if(svgClass[0] === 'y') {
120132
mathjaxGroup.attr({
121133
transform: 'rotate(' + [-90, x, y] +
122-
')' + strTranslate(-newSvgW / 2, dy - newSvgH / 2)
134+
')' + strTranslate(-w / 2, dy - h / 2)
123135
});
124136
} else if(svgClass[0] === 'l') {
125-
y = dy - newSvgH / 2;
137+
y = dy - h / 2;
126138
} else if(svgClass[0] === 'a' && svgClass.indexOf('atitle') !== 0) {
127139
x = 0;
128140
y = dy;
129141
} else {
130142
var anchor = _context.attr('text-anchor');
131143

132-
x = x - newSvgW * (
144+
x = x - w * (
133145
anchor === 'middle' ? 0.5 :
134146
anchor === 'end' ? 1 : 0
135147
);
136-
y = y + dy - newSvgH / 2;
148+
y = y + dy - h / 2;
137149
}
138150

139151
newSvg.attr({

Diff for: tasks/test_syntax.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ assertCircularDeps();
3131
// check for for focus and exclude jasmine blocks
3232
function assertJasmineSuites() {
3333
var BLACK_LIST = ['fdescribe', 'fit', 'xdescribe', 'xit'];
34-
var TAGS = ['noCI', 'noCIdep', 'gl', 'flaky'];
34+
var TAGS = ['noCI', 'noCIdep', 'noFF82', 'gl', 'flaky'];
3535
var IT_ONLY_TAGS = ['gl', 'flaky'];
3636
var logs = [];
3737

Diff for: test/jasmine/bundle_tests/mathjax_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('Test MathJax:', function() {
9898
.then(done, done.fail);
9999
});
100100

101-
it('should scoot x-axis title (with MathJax) below x-axis ticks', function(done) {
101+
it('@noFF82 should scoot x-axis title (with MathJax) below x-axis ticks', function(done) {
102102
expect(window.MathJax).toBeDefined();
103103

104104
testTitleScoot({

0 commit comments

Comments
 (0)