@mackin.com/styleguide 8.0.0-beta.20 → 8.0.0-beta.21

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/index.js +14 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1123,7 +1123,7 @@ const useLogger = (componentName, enabled) => {
1123
1123
  return (...messages) => {
1124
1124
  if (enabled) {
1125
1125
  // tslint:disable-next-line
1126
- console.log(componentName, ...messages);
1126
+ console.log(`[${componentName}]`, ...messages);
1127
1127
  }
1128
1128
  };
1129
1129
  };
@@ -1463,17 +1463,22 @@ const Modal = (p) => {
1463
1463
  const theme = useThemeSafely();
1464
1464
  const hasHeader = p.closeButton || p.heading;
1465
1465
  const contentRef = React__default['default'].useRef(null);
1466
- const log = useLogger(`Modal ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
1466
+ const log = useLogger((_a = p.id) !== null && _a !== void 0 ? _a : 'Modal', (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
1467
+ const tryRemoveBodyStyles = () => {
1468
+ if (backdrop.showCount <= 1 && htmlBodyStyles) {
1469
+ log('backdrop.showCount', backdrop.showCount, 'removing singleton htmlBodyStyles');
1470
+ document.body.classList.remove(htmlBodyStyles);
1471
+ }
1472
+ };
1467
1473
  React.useEffect(() => {
1468
1474
  log('mounted');
1469
1475
  return () => {
1470
1476
  var _a;
1471
1477
  // handle the use of modals that are rendered only as show=true and then unmounted.
1472
- backdrop.setShow(false, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
1473
- log('backdrop.setShow', false);
1474
- if (backdrop.showCount <= 1 && htmlBodyStyles) {
1475
- log('backdrop.showCount', backdrop.showCount, 'removing htmlBodyStyles');
1476
- document.body.classList.remove(htmlBodyStyles);
1478
+ if (p.show) {
1479
+ backdrop.setShow(false, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
1480
+ log('backdrop.setShow', false);
1481
+ tryRemoveBodyStyles();
1477
1482
  }
1478
1483
  log('un-mounted');
1479
1484
  };
@@ -1491,14 +1496,11 @@ const Modal = (p) => {
1491
1496
  });
1492
1497
  }
1493
1498
  if (show) {
1494
- log('adding htmlBodyStyles');
1499
+ log('adding singleton htmlBodyStyles');
1495
1500
  document.body.classList.add(htmlBodyStyles);
1496
1501
  }
1497
1502
  else {
1498
- if (backdrop.showCount <= 1) {
1499
- log('backdrop.showCount', backdrop.showCount, 'removing htmlBodyStyles');
1500
- document.body.classList.remove(htmlBodyStyles);
1501
- }
1503
+ tryRemoveBodyStyles();
1502
1504
  }
1503
1505
  }, p.show);
1504
1506
  React__default['default'].useLayoutEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "8.0.0-beta.20",
3
+ "version": "8.0.0-beta.21",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",