@ngbracket/a11y-devtools 0.15.0 → 0.15.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to `@ngbracket/a11y-devtools` are documented here.
4
4
  This project adheres to [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## 0.15.1
7
+
8
+ ### Fixed
9
+
10
+ - **Collapsed sidebars no longer cause false tab-order findings.** A
11
+ `<details>` nested inside a closed `<details>` (a group inside a collapsed
12
+ sidebar section) had its summary counted as a tab stop, although it's hidden
13
+ and Tab can't reach it. The next section's summary then looked like a jump
14
+ back up the page, so `ngbr/tab-order-mismatch` fired once per section. Every
15
+ closed `<details>` up the tree now counts. This also fixes the tab-order
16
+ badges in the overlay. Found on our own docs site.
17
+ - **`ngbr/unreachable-control` skips hidden controls.** A custom control inside
18
+ a closed `<details>`, a `[hidden]` or `inert` subtree, or `display: none` was
19
+ reported as unreachable. Tab can't reach it because it isn't shown, which
20
+ isn't a problem; it's checked once it's shown.
21
+
6
22
  ## 0.15.0
7
23
 
8
24
  ### Added
@@ -7129,7 +7129,7 @@
7129
7129
  isContextSpec: function isContextSpec() {
7130
7130
  return _isContextSpec;
7131
7131
  },
7132
- isHidden: function isHidden2() {
7132
+ isHidden: function isHidden3() {
7133
7133
  return is_hidden_default;
7134
7134
  },
7135
7135
  isHtmlElement: function isHtmlElement() {
@@ -19809,7 +19809,7 @@
19809
19809
  function _isLabelledShadowDomSelector(selector) {
19810
19810
  return _objectHasOwn(selector, "fromShadowDom");
19811
19811
  }
19812
- function isHidden(el, recursed) {
19812
+ function isHidden2(el, recursed) {
19813
19813
  var node = get_node_from_tree_default(el);
19814
19814
  if (el.nodeType === 9) {
19815
19815
  return false;
@@ -19825,13 +19825,13 @@
19825
19825
  return true;
19826
19826
  }
19827
19827
  var parent = el.assignedSlot ? el.assignedSlot : el.parentNode;
19828
- var hidden = isHidden(parent, true);
19828
+ var hidden = isHidden2(parent, true);
19829
19829
  if (node) {
19830
19830
  node._isHidden = hidden;
19831
19831
  }
19832
19832
  return hidden;
19833
19833
  }
19834
- var is_hidden_default = isHidden;
19834
+ var is_hidden_default = isHidden2;
19835
19835
  function _isHtmlElement(node) {
19836
19836
  var _node$props$nodeName, _node$props;
19837
19837
  var nodeName2 = (_node$props$nodeName = (_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.nodeName) !== null && _node$props$nodeName !== void 0 ? _node$props$nodeName : node.nodeName.toLowerCase();
@@ -34696,8 +34696,14 @@
34696
34696
  function isStructurallyHidden(element) {
34697
34697
  if (element.closest("[inert]") || element.closest("[hidden]"))
34698
34698
  return true;
34699
- const closedDetails = element.closest("details:not([open])");
34700
- return closedDetails !== null && element.closest("summary") === null && element !== closedDetails;
34699
+ for (let details = element.closest("details:not([open])"); details; details = details.parentElement?.closest("details:not([open])") ?? null) {
34700
+ if (details === element)
34701
+ continue;
34702
+ const summary = [...details.children].find((child) => child.tagName.toLowerCase() === "summary");
34703
+ if (!summary?.contains(element))
34704
+ return true;
34705
+ }
34706
+ return false;
34701
34707
  }
34702
34708
  function defaultIsVisible(element) {
34703
34709
  const view = element.ownerDocument?.defaultView;
@@ -34712,6 +34718,9 @@
34712
34718
  }
34713
34719
  return true;
34714
34720
  }
34721
+ function isHidden(element, isVisible = defaultIsVisible) {
34722
+ return isStructurallyHidden(element) || !isVisible(element);
34723
+ }
34715
34724
  function isTabbable(element, isVisible = defaultIsVisible) {
34716
34725
  if (resolvedTabIndex(element) < 0)
34717
34726
  return false;
@@ -34867,6 +34876,8 @@
34867
34876
  continue;
34868
34877
  if (!interactiveByRole && hasFocusableDescendant(element))
34869
34878
  continue;
34879
+ if (isHidden(element, isVisible))
34880
+ continue;
34870
34881
  const focusable = isTabbable(element, isVisible);
34871
34882
  if (!focusable) {
34872
34883
  const reason = interactiveByRole ? `has role="${role}"` : "has a click handler";
@@ -12,7 +12,7 @@
12
12
  * confirmed failures.
13
13
  */
14
14
  import { appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, resolveComponentPath, resolveDirectiveNames, resolveListenerEvents, } from '../attribution.js';
15
- import { hasFocusableDescendant, isNativelyFocusable, isTabbable, tabSequence, visualOrderJumps, } from './tab-sequence.js';
15
+ import { hasFocusableDescendant, isHidden, isNativelyFocusable, isTabbable, tabSequence, visualOrderJumps, } from './tab-sequence.js';
16
16
  import { findUncontainedModals } from './focus-trap.js';
17
17
  import { blockingModalDialog } from '../top-layer.js';
18
18
  /** WAI-ARIA roles that make a non-native element behave as an interactive control. */
@@ -103,6 +103,10 @@ export function scanKeyboard(root = document, options = {}) {
103
103
  // the keyboard reaches.
104
104
  if (!interactiveByRole && hasFocusableDescendant(element))
105
105
  continue;
106
+ // Hidden (a closed <details>, [hidden], display:none): not reachable because
107
+ // it isn't shown. Check it when it is.
108
+ if (isHidden(element, isVisible))
109
+ continue;
106
110
  const focusable = isTabbable(element, isVisible);
107
111
  if (!focusable) {
108
112
  const reason = interactiveByRole ? `has role="${role}"` : 'has a click handler';
@@ -57,6 +57,12 @@ export declare function isNativelyFocusable(element: Element): boolean;
57
57
  * `tabindex="foo"`) is ignored by browsers, so it falls back to the native value.
58
58
  */
59
59
  export declare function resolvedTabIndex(element: Element): number;
60
+ /**
61
+ * True when `element` isn't shown at all: structurally hidden (see
62
+ * {@link isStructurallyHidden}) or hidden by layout. A hidden control is out of
63
+ * the tab order because nobody can see it, not because it's unreachable.
64
+ */
65
+ export declare function isHidden(element: Element, isVisible?: (el: Element) => boolean): boolean;
60
66
  /**
61
67
  * True when `element` participates in sequential keyboard navigation: it's
62
68
  * focusable, has a resolved `tabindex >= 0`, and is neither disabled nor hidden.
@@ -129,12 +129,23 @@ function isDisabled(element) {
129
129
  * layout: inside an `[inert]` or `[hidden]` subtree, or non-summary content of a
130
130
  * closed `<details>`. Kept separate from the layout check so the injectable
131
131
  * visibility predicate only ever overrides computed-style visibility.
132
+ *
133
+ * Every closed `<details>` up the tree counts, not just the nearest: a nested
134
+ * `<details>` (a sidebar group inside a collapsed section) has its own summary,
135
+ * but that summary is hidden too while an outer one is closed.
132
136
  */
133
137
  function isStructurallyHidden(element) {
134
138
  if (element.closest('[inert]') || element.closest('[hidden]'))
135
139
  return true;
136
- const closedDetails = element.closest('details:not([open])');
137
- return closedDetails !== null && element.closest('summary') === null && element !== closedDetails;
140
+ for (let details = element.closest('details:not([open])'); details; details = details.parentElement?.closest('details:not([open])') ?? null) {
141
+ if (details === element)
142
+ continue;
143
+ // Only this <details>' own summary (its first <summary> child) stays shown.
144
+ const summary = [...details.children].find((child) => child.tagName.toLowerCase() === 'summary');
145
+ if (!summary?.contains(element))
146
+ return true;
147
+ }
148
+ return false;
138
149
  }
139
150
  /** Layout-aware default visibility: computed `display`/`visibility` up the tree. */
140
151
  function defaultIsVisible(element) {
@@ -150,6 +161,14 @@ function defaultIsVisible(element) {
150
161
  }
151
162
  return true;
152
163
  }
164
+ /**
165
+ * True when `element` isn't shown at all: structurally hidden (see
166
+ * {@link isStructurallyHidden}) or hidden by layout. A hidden control is out of
167
+ * the tab order because nobody can see it, not because it's unreachable.
168
+ */
169
+ export function isHidden(element, isVisible = defaultIsVisible) {
170
+ return isStructurallyHidden(element) || !isVisible(element);
171
+ }
153
172
  /**
154
173
  * True when `element` participates in sequential keyboard navigation: it's
155
174
  * focusable, has a resolved `tabindex >= 0`, and is neither disabled nor hidden.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngbracket/a11y-devtools",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Dev-only in-app accessibility auditing for Angular that maps each axe violation back to the component that rendered it — the attribution React overlay tools can't do.",
5
5
  "license": "MIT",
6
6
  "author": "Duncan Faulkner",