dash-core-components 4.4.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -462,28 +462,35 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
462
462
  relayoutData: relayout
463
463
  });
464
464
  }
465
- // Sync shapes from gd.layout to figure when shapes are modified by user
466
- // This is needed because getLayout() clones layout to prevent mutation issues
465
+ // Sync user-driven layout changes (pan/zoom ranges, edited
466
+ // shapes, annotations, ...) from gd.layout back to the figure
467
+ // prop. This is needed because getLayout() clones layout to
468
+ // prevent mutation issues, so plotly.js only updates its own
469
+ // copy and the figure prop (used as the base for Patch
470
+ // updates) would otherwise go stale.
467
471
  if (eventData && gd.layout) {
468
- var hasShapeChanges = Object.keys(eventData).some(function (key) {
469
- return key === 'shapes' || key.startsWith('shapes[');
470
- });
471
- if (hasShapeChanges) {
472
+ var _this4$props$figure = _this4.props.figure,
473
+ figure = _this4$props$figure === void 0 ? {} : _this4$props$figure;
474
+ var updates = {};
475
+ for (var _i = 0, _Object$keys = Object.keys(eventData); _i < _Object$keys.length; _i++) {
472
476
  var _figure$layout;
473
- var _this4$props$figure = _this4.props.figure,
474
- figure = _this4$props$figure === void 0 ? {} : _this4$props$figure;
475
- var currentShapes = figure === null || figure === void 0 || (_figure$layout = figure.layout) === null || _figure$layout === void 0 ? void 0 : _figure$layout.shapes;
476
- var newShapes = gd.layout.shapes;
477
- if (!(0, _ramda.equals)(currentShapes, newShapes)) {
478
- setProps({
479
- figure: _objectSpread(_objectSpread({}, figure), {}, {
480
- layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), {}, {
481
- shapes: newShapes
482
- })
483
- })
484
- });
477
+ var eventKey = _Object$keys[_i];
478
+ // 'xaxis.range[0]' -> 'xaxis', 'shapes[1].x0' -> 'shapes'
479
+ var key = eventKey.split('.')[0].split('[')[0];
480
+ if (
481
+ // autosize/width/height relayouts come from the
482
+ // resize machinery, not from user interactions.
483
+ !(0, _ramda.includes)(key, ['autosize', 'width', 'height']) && !(key in updates) && !(0, _ramda.equals)(figure === null || figure === void 0 || (_figure$layout = figure.layout) === null || _figure$layout === void 0 ? void 0 : _figure$layout[key], gd.layout[key])) {
484
+ updates[key] = (0, _ramda.clone)(gd.layout[key]);
485
485
  }
486
486
  }
487
+ if (Object.keys(updates).length) {
488
+ setProps({
489
+ figure: _objectSpread(_objectSpread({}, figure), {}, {
490
+ layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), updates)
491
+ })
492
+ });
493
+ }
487
494
  }
488
495
  });
489
496
  gd.on('plotly_restyle', function (eventData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-core-components",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "Core component suite for Dash",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,10 +41,10 @@
41
41
  "@fortawesome/free-solid-svg-icons": "^5.15.4",
42
42
  "@fortawesome/react-fontawesome": "^0.1.17",
43
43
  "@radix-ui/react-icons": "^1.3.2",
44
- "@radix-ui/react-popover": "^1.1.15",
45
- "@radix-ui/react-select": "^2.1.3",
46
- "@radix-ui/react-slider": "^1.3.6",
47
- "@radix-ui/react-tooltip": "^1.2.8",
44
+ "@radix-ui/react-popover": "^1.1.20",
45
+ "@radix-ui/react-select": "^2.3.4",
46
+ "@radix-ui/react-slider": "^1.4.4",
47
+ "@radix-ui/react-tooltip": "^1.2.13",
48
48
  "base64-js": "^1.5.1",
49
49
  "d3-format": "^1.4.5",
50
50
  "date-fns": "^4.1.0",