@micromag/screen-keypad 0.4.55 → 0.4.57

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.
Files changed (2) hide show
  1. package/es/index.js +21 -8
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -6,7 +6,7 @@ import { animated } from '@react-spring/web';
6
6
  import classNames from 'classnames';
7
7
  import isEmpty from 'lodash/isEmpty';
8
8
  import isString from 'lodash/isString';
9
- import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
9
+ import { useRef, useState, useMemo, useEffect, useCallback } from 'react';
10
10
  import { Close, ScreenElement } from '@micromag/core/components';
11
11
  import { usePlaybackContext, usePlaybackMediaRef, useScreenState, useScreenSize, useViewerContext, useViewerWebView, useViewerInteraction, useScreenRenderContext } from '@micromag/core/contexts';
12
12
  import { useTrackScreenEvent, useDimensionObserver, useDragProgress } from '@micromag/core/hooks';
@@ -227,6 +227,18 @@ function KeypadScreen(_ref) {
227
227
  popupInWebView = _ref10$inWebView === void 0 ? false : _ref10$inWebView,
228
228
  _ref10$boxStyle = _ref10.boxStyle,
229
229
  popupButtonBoxStyle = _ref10$boxStyle === void 0 ? null : _ref10$boxStyle;
230
+
231
+ // Skips a render loop when opening a popup
232
+ var _useState7 = useState(false),
233
+ _useState8 = _slicedToArray(_useState7, 2),
234
+ showNextPopup = _useState8[0],
235
+ setShowNextPopup = _useState8[1];
236
+ useEffect(function () {
237
+ if (showNextPopup) {
238
+ setShowNextPopup(false);
239
+ setShowPopup(true);
240
+ }
241
+ }, [showNextPopup, setShowPopup, setShowNextPopup]);
230
242
  var onItemClick = useCallback(function (e, item, index) {
231
243
  e.stopPropagation();
232
244
  if (isNotInteractive) {
@@ -247,7 +259,7 @@ function KeypadScreen(_ref) {
247
259
  });
248
260
  } else {
249
261
  setPopup(item);
250
- setShowPopup(true);
262
+ setShowNextPopup(true);
251
263
  }
252
264
  var _ref12 = heading || {},
253
265
  _ref12$body = _ref12.body,
@@ -285,10 +297,10 @@ function KeypadScreen(_ref) {
285
297
  e.stopPropagation();
286
298
  }
287
299
  }, []);
288
- var _useState7 = useState(null),
289
- _useState8 = _slicedToArray(_useState7, 2),
290
- popupDragDirection = _useState8[0],
291
- setPopupDragDirection = _useState8[1];
300
+ var _useState9 = useState(null),
301
+ _useState0 = _slicedToArray(_useState9, 2),
302
+ popupDragDirection = _useState0[0],
303
+ setPopupDragDirection = _useState0[1];
292
304
  var onPopupScrollHeightChange = useCallback(function (_ref13) {
293
305
  var _ref13$scrolleeHeight = _ref13.scrolleeHeight,
294
306
  scrolleeHeight = _ref13$scrolleeHeight === void 0 ? 0 : _ref13$scrolleeHeight;
@@ -387,6 +399,7 @@ function KeypadScreen(_ref) {
387
399
  // Clear popup contents after close transition completes
388
400
  useEffect(function () {
389
401
  if (prevShowPopupRef.current && !showPopup && !popupTransitioning) {
402
+ console.log('clear popup');
390
403
  setPopup(null);
391
404
  }
392
405
  prevShowPopupRef.current = showPopup;
@@ -593,7 +606,7 @@ function KeypadScreen(_ref) {
593
606
  spacing: isPlaceholder ? 2 : columnSpacing,
594
607
  items: gridItems
595
608
  })]
596
- }), popup !== null ? /*#__PURE__*/jsxs(Fragment, {
609
+ }), /*#__PURE__*/jsxs(Fragment, {
597
610
  children: [/*#__PURE__*/jsx(animated.div, {
598
611
  className: classNames([styles.popupBackdrop]),
599
612
  style: {
@@ -703,7 +716,7 @@ function KeypadScreen(_ref) {
703
716
  })
704
717
  })
705
718
  }))]
706
- }) : null]
719
+ }) ]
707
720
  }), !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
708
721
  ref: footerRef,
709
722
  className: styles.footer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-keypad",
3
- "version": "0.4.55",
3
+ "version": "0.4.57",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -94,6 +94,6 @@
94
94
  "access": "public",
95
95
  "registry": "https://registry.npmjs.org/"
96
96
  },
97
- "gitHead": "9708f0016de0cf18dcd6a6aa5bc70d7f00b86d9f",
97
+ "gitHead": "fbe8859ecf20634ed5591afb432ff4869eb37352",
98
98
  "types": "es/index.d.ts"
99
99
  }