@enact/ui 4.5.5 → 4.5.6

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact ui module, newest changes on the top.
4
4
 
5
+ ## [4.5.6] - 2023-11-30
6
+
7
+ ### Fixed
8
+
9
+ - `ui/Marquee.MarqueeDecorator` to re-render when its size changed
10
+
5
11
  ## [4.5.5] - 2023-11-08
6
12
 
7
13
  No significant changes.
@@ -396,11 +396,13 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
396
396
  _this.distance = null;
397
397
  _this.contentFits = null;
398
398
  _this.resizeRegistry = null;
399
+ _this.resizeObserver = null;
399
400
  return _this;
400
401
  }
401
402
  _createClass(_class, [{
402
403
  key: "componentDidMount",
403
404
  value: function componentDidMount() {
405
+ var _this2 = this;
404
406
  if (this.context && this.context.register) {
405
407
  this.sync = true;
406
408
  this.context.register(this, {
@@ -409,6 +411,12 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
409
411
  });
410
412
  }
411
413
  this.validateTextDirection();
414
+ if (typeof ResizeObserver === 'function' && this.node) {
415
+ this.resizeObserver = new ResizeObserver(function () {
416
+ _this2.handleResize();
417
+ });
418
+ this.resizeObserver.observe(this.node);
419
+ }
412
420
  if (this.props.marqueeOn === 'render') {
413
421
  this.startAnimation(this.props.marqueeOnRenderDelay);
414
422
  }
@@ -458,6 +466,10 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
458
466
  if (this.resizeRegistry) {
459
467
  this.resizeRegistry.unregister(this.handleResize);
460
468
  }
469
+ if (this.resizeObserver) {
470
+ this.resizeObserver.disconnect();
471
+ this.resizeObserver = null;
472
+ }
461
473
  (0, _dispatcher.off)('keydown', this.handlePointerHide, document);
462
474
  }
463
475
  }, {
@@ -501,14 +513,14 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
501
513
  }, {
502
514
  key: "setTimeout",
503
515
  value: function setTimeout(fn) {
504
- var _this2 = this;
516
+ var _this3 = this;
505
517
  var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
506
518
  var state = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TimerState.CLEAR;
507
519
  this.clearTimeout();
508
520
  if (window) {
509
521
  this.timerState = state;
510
522
  this.timer = window.setTimeout(function () {
511
- _this2.timerState = TimerState.CLEAR;
523
+ _this3.timerState = TimerState.CLEAR;
512
524
  fn();
513
525
  }, time);
514
526
  }
@@ -699,9 +711,9 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
699
711
  }, {
700
712
  key: "validateTextDirection",
701
713
  value: function validateTextDirection() {
702
- var _this3 = this;
714
+ var _this4 = this;
703
715
  this.setState(function (state, props) {
704
- var rtl = determineTextDirection(_this3.node, props.rtl, props.forceDirection);
716
+ var rtl = determineTextDirection(_this4.node, props.rtl, props.forceDirection);
705
717
  return state.rtl === rtl ? null : {
706
718
  rtl: rtl
707
719
  };
@@ -784,16 +796,16 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
784
796
  }, {
785
797
  key: "render",
786
798
  value: function render() {
787
- var _this4 = this;
799
+ var _this5 = this;
788
800
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Resizable.ResizeContext.Consumer, {
789
801
  children: function children(register) {
790
- if (!_this4.resizeRegistry && register) {
791
- _this4.resizeRegistry = register(_this4.handleResize);
802
+ if (!_this5.resizeRegistry && register) {
803
+ _this5.resizeRegistry = register(_this5.handleResize);
792
804
  }
793
- if (_this4.props.marqueeDisabled) {
794
- return _this4.renderWrapped();
805
+ if (_this5.props.marqueeDisabled) {
806
+ return _this5.renderWrapped();
795
807
  } else {
796
- return _this4.renderMarquee();
808
+ return _this5.renderMarquee();
797
809
  }
798
810
  }
799
811
  });
@@ -298,6 +298,25 @@ describe('Marquee', function () {
298
298
  _react.fireEvent.mouseLeave(marquee);
299
299
  expect(spy).toHaveBeenCalled();
300
300
  });
301
+ test('should creates and observes with ResizeObserver', function () {
302
+ var originalResizeObserver = global.ResizeObserver;
303
+ var observe = jest.fn();
304
+ global.ResizeObserver = jest.fn(function () {
305
+ return {
306
+ observe: observe,
307
+ disconnect: jest.fn()
308
+ };
309
+ });
310
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Marquee, {
311
+ children: ltrText
312
+ }));
313
+ (0, _react.act)(function () {
314
+ return jest.advanceTimersByTime(100);
315
+ });
316
+ expect(global.ResizeObserver).toHaveBeenCalled();
317
+ expect(observe).toHaveBeenCalled();
318
+ global.ResizeObserver = originalResizeObserver;
319
+ });
301
320
  });
302
321
  describe('MarqueeBase', function () {
303
322
  // Computed Property Tests
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/ui",
3
- "version": "4.5.5",
3
+ "version": "4.5.6",
4
4
  "description": "A collection of simplified unstyled cross-platform UI components for Enact",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@enact/core": "^4.5.5",
34
+ "@enact/core": "^4.5.6",
35
35
  "classnames": "^2.3.1",
36
36
  "direction": "^1.0.4",
37
37
  "invariant": "^2.2.4",