@atlaskit/top-layer 4.4.4 → 4.4.5

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
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/top-layer
2
2
 
3
+ ## 4.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4aa51e925cecb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4aa51e925cecb) -
8
+ Handle environments that do not support matching the `:popover-open` selector during close
9
+ settlement.
10
+
3
11
  ## 4.4.4
4
12
 
5
13
  ### Patch Changes
@@ -50,7 +50,13 @@ function isNativeElementOpen(_ref3) {
50
50
  if (element instanceof HTMLDialogElement) {
51
51
  return element.open;
52
52
  }
53
- return element.matches(':popover-open');
53
+
54
+ // Some DOM implementations throw for unsupported pseudo-classes.
55
+ try {
56
+ return element.matches(':popover-open');
57
+ } catch (_unused) {
58
+ return false;
59
+ }
54
60
  }
55
61
 
56
62
  /**
@@ -257,11 +263,12 @@ function useAnimatedVisibility(_ref5) {
257
263
  cancelExitSettlementRef.current();
258
264
  // Snapshot currentTarget because the DOM clears it after event dispatch.
259
265
  var element = event.currentTarget;
260
- if (element instanceof HTMLElement) {
261
- if (event.newState === 'open') {
262
- element.removeAttribute('inert');
263
- element.removeAttribute('aria-hidden');
264
- } else {
266
+ if (event.newState === 'open' && element instanceof HTMLElement) {
267
+ element.removeAttribute('inert');
268
+ element.removeAttribute('aria-hidden');
269
+ }
270
+ if (event.newState === 'closed') {
271
+ if (element instanceof HTMLElement) {
265
272
  // We use a microtask to let native focus restoration happen before making the element inert.
266
273
  // The browser restores focus after beforetoggle returns, during its close steps.
267
274
  queueMicrotask(function () {
@@ -272,13 +279,13 @@ function useAnimatedVisibility(_ref5) {
272
279
  })) {
273
280
  return;
274
281
  }
282
+
283
+ // Exit animations keep closed content rendered, so make it non-interactive and hide it from assistive technology.
275
284
  element.setAttribute('inert', '');
276
285
  // Tooling does not consistently treat inert content as hidden, even though the browser does.
277
286
  element.setAttribute('aria-hidden', 'true');
278
287
  });
279
288
  }
280
- }
281
- if (event.newState === 'closed') {
282
289
  dispatch({
283
290
  type: 'exit-started'
284
291
  });
@@ -40,7 +40,13 @@ function isNativeElementOpen({
40
40
  if (element instanceof HTMLDialogElement) {
41
41
  return element.open;
42
42
  }
43
- return element.matches(':popover-open');
43
+
44
+ // Some DOM implementations throw for unsupported pseudo-classes.
45
+ try {
46
+ return element.matches(':popover-open');
47
+ } catch {
48
+ return false;
49
+ }
44
50
  }
45
51
 
46
52
  /**
@@ -253,11 +259,12 @@ export function useAnimatedVisibility({
253
259
  cancelExitSettlementRef.current();
254
260
  // Snapshot currentTarget because the DOM clears it after event dispatch.
255
261
  const element = event.currentTarget;
256
- if (element instanceof HTMLElement) {
257
- if (event.newState === 'open') {
258
- element.removeAttribute('inert');
259
- element.removeAttribute('aria-hidden');
260
- } else {
262
+ if (event.newState === 'open' && element instanceof HTMLElement) {
263
+ element.removeAttribute('inert');
264
+ element.removeAttribute('aria-hidden');
265
+ }
266
+ if (event.newState === 'closed') {
267
+ if (element instanceof HTMLElement) {
261
268
  // We use a microtask to let native focus restoration happen before making the element inert.
262
269
  // The browser restores focus after beforetoggle returns, during its close steps.
263
270
  queueMicrotask(() => {
@@ -268,13 +275,13 @@ export function useAnimatedVisibility({
268
275
  })) {
269
276
  return;
270
277
  }
278
+
279
+ // Exit animations keep closed content rendered, so make it non-interactive and hide it from assistive technology.
271
280
  element.setAttribute('inert', '');
272
281
  // Tooling does not consistently treat inert content as hidden, even though the browser does.
273
282
  element.setAttribute('aria-hidden', 'true');
274
283
  });
275
284
  }
276
- }
277
- if (event.newState === 'closed') {
278
285
  dispatch({
279
286
  type: 'exit-started'
280
287
  });
@@ -43,7 +43,13 @@ function isNativeElementOpen(_ref3) {
43
43
  if (element instanceof HTMLDialogElement) {
44
44
  return element.open;
45
45
  }
46
- return element.matches(':popover-open');
46
+
47
+ // Some DOM implementations throw for unsupported pseudo-classes.
48
+ try {
49
+ return element.matches(':popover-open');
50
+ } catch (_unused) {
51
+ return false;
52
+ }
47
53
  }
48
54
 
49
55
  /**
@@ -250,11 +256,12 @@ export function useAnimatedVisibility(_ref5) {
250
256
  cancelExitSettlementRef.current();
251
257
  // Snapshot currentTarget because the DOM clears it after event dispatch.
252
258
  var element = event.currentTarget;
253
- if (element instanceof HTMLElement) {
254
- if (event.newState === 'open') {
255
- element.removeAttribute('inert');
256
- element.removeAttribute('aria-hidden');
257
- } else {
259
+ if (event.newState === 'open' && element instanceof HTMLElement) {
260
+ element.removeAttribute('inert');
261
+ element.removeAttribute('aria-hidden');
262
+ }
263
+ if (event.newState === 'closed') {
264
+ if (element instanceof HTMLElement) {
258
265
  // We use a microtask to let native focus restoration happen before making the element inert.
259
266
  // The browser restores focus after beforetoggle returns, during its close steps.
260
267
  queueMicrotask(function () {
@@ -265,13 +272,13 @@ export function useAnimatedVisibility(_ref5) {
265
272
  })) {
266
273
  return;
267
274
  }
275
+
276
+ // Exit animations keep closed content rendered, so make it non-interactive and hide it from assistive technology.
268
277
  element.setAttribute('inert', '');
269
278
  // Tooling does not consistently treat inert content as hidden, even though the browser does.
270
279
  element.setAttribute('aria-hidden', 'true');
271
280
  });
272
281
  }
273
- }
274
- if (event.newState === 'closed') {
275
282
  dispatch({
276
283
  type: 'exit-started'
277
284
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/top-layer",
3
- "version": "4.4.4",
3
+ "version": "4.4.5",
4
4
  "description": "Low-level layering primitives based on popover and dialog",
5
5
  "homepage": "https://atlassian.design/components/top-layer",
6
6
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",