Skip to content

Commit e46312f

Browse files
Merge pull request #184 from martinRenou/respect_widget_layout
Respect the widget layout
2 parents add2c08 + 1cd3c44 commit e46312f

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

js/src/mpl_widget.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
.jupyter-matplotlib {
2-
flex: 1 1 auto;
32
width: auto;
43
height: auto;
4+
flex: 1 1 auto;
55
}
66

77
/* Toolbar */
88

99
.jupyter-matplotlib-toolbar {
10-
flex: 0 0 auto;
10+
overflow: visible;
1111
}
1212

1313
.jupyter-matplotlib-button {
@@ -24,11 +24,15 @@
2424
overflow: hidden;
2525
}
2626

27-
.jupyter-matplotlib-canvas_div {
27+
.jupyter-matplotlib-canvas-container {
28+
overflow: auto;
29+
}
30+
31+
.jupyter-matplotlib-canvas-div {
2832
margin: 2px;
2933
flex: 1 1 auto;
3034
}
3135

32-
.jupyter-matplotlib-canvas_div:focus {
36+
.jupyter-matplotlib-canvas-div:focus {
3337
outline: 1px solid var(--jp-widgets-input-focus-border-color);
3438
}

js/src/mpl_widget.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,21 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
339339
},
340340

341341
_init_canvas: function() {
342+
var canvas_container = document.createElement('div');
343+
canvas_container.classList = 'jupyter-widgets jupyter-matplotlib-canvas-container';
344+
this.figure.appendChild(canvas_container);
345+
342346
var canvas_div = this.canvas_div = document.createElement('div');
343347
canvas_div.style.position = 'relative';
344348
canvas_div.style.clear = 'both';
345-
canvas_div.classList = 'jupyter-widgets jupyter-matplotlib-canvas_div';
349+
canvas_div.classList = 'jupyter-widgets jupyter-matplotlib-canvas-div';
346350

347351
canvas_div.addEventListener('keydown', this.key_event('key_press'));
348352
canvas_div.addEventListener('keyup', this.key_event('key_release'));
349353

350354
// this is important to make the div 'focusable'
351355
canvas_div.setAttribute('tabindex', 0);
352-
this.figure.appendChild(canvas_div);
356+
canvas_container.appendChild(canvas_div);
353357

354358
var canvas = this.canvas = document.createElement('canvas');
355359
canvas.style.display = 'block';
@@ -520,12 +524,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
520524
step: event.step,
521525
guiEvent: utils.get_simple_keys(event)});
522526
}
523-
524-
/* This prevents the web browser from automatically changing to
525-
* the text insertion cursor when the button is pressed. We want
526-
* to control all of the cursor setting manually through the
527-
* 'cursor' event from matplotlib */
528-
event.preventDefault();
529527
};
530528
},
531529

0 commit comments

Comments
 (0)