@primer/view-components 0.50.0 → 0.50.1-rc.3cbb9623

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.
@@ -15,7 +15,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
15
15
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
16
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
17
  };
18
- var _TreeViewSubTreeNodeElement_instances, _TreeViewSubTreeNodeElement_expanded, _TreeViewSubTreeNodeElement_loadingState, _TreeViewSubTreeNodeElement_abortController, _TreeViewSubTreeNodeElement_activeElementIsLoader, _TreeViewSubTreeNodeElement_handleToggleEvent, _TreeViewSubTreeNodeElement_handleIncludeFragmentEvent, _TreeViewSubTreeNodeElement_handleRetryButtonEvent, _TreeViewSubTreeNodeElement_handleKeyboardEvent, _TreeViewSubTreeNodeElement_handleCheckboxEvent, _TreeViewSubTreeNodeElement_update, _TreeViewSubTreeNodeElement_checkboxElement_get;
18
+ var _TreeViewSubTreeNodeElement_instances, _TreeViewSubTreeNodeElement_expanded, _TreeViewSubTreeNodeElement_loadingState, _TreeViewSubTreeNodeElement_abortController, _TreeViewSubTreeNodeElement_activeElementIsLoader, _TreeViewSubTreeNodeElement_handleToggleEvent, _TreeViewSubTreeNodeElement_handleIncludeFragmentEvent, _TreeViewSubTreeNodeElement_handleRetryButtonEvent, _TreeViewSubTreeNodeElement_handleKeyboardEvent, _TreeViewSubTreeNodeElement_handleCheckboxEvent, _TreeViewSubTreeNodeElement_update, _TreeViewSubTreeNodeElement_isIncludeFragment, _TreeViewSubTreeNodeElement_checkboxElement_get;
19
19
  import { controller, target } from '@github/catalyst';
20
20
  import { observeMutationsUntilConditionMet } from '../../utils';
21
21
  let TreeViewSubTreeNodeElement = class TreeViewSubTreeNodeElement extends HTMLElement {
@@ -134,6 +134,10 @@ let TreeViewSubTreeNodeElement = class TreeViewSubTreeNodeElement extends HTMLEl
134
134
  // sub-tree and no node in the entire tree can be focused
135
135
  const previousNode = this.subTree.querySelector("[tabindex='0']");
136
136
  previousNode?.setAttribute('tabindex', '-1');
137
+ // Also check if the subtree element itself is an include-fragment with role="treeitem" and has focus
138
+ if (__classPrivateFieldGet(this, _TreeViewSubTreeNodeElement_instances, "m", _TreeViewSubTreeNodeElement_isIncludeFragment).call(this) && this.subTree.getAttribute('tabindex') === '0') {
139
+ this.subTree.setAttribute('tabindex', '-1');
140
+ }
137
141
  this.node.setAttribute('tabindex', '0');
138
142
  this.treeView.dispatchEvent(new CustomEvent('treeViewNodeCollapsed', {
139
143
  bubbles: true,
@@ -237,6 +241,10 @@ _TreeViewSubTreeNodeElement_handleIncludeFragmentEvent = function _TreeViewSubTr
237
241
  // request succeeded but element has not yet been replaced
238
242
  case 'include-fragment-replace':
239
243
  __classPrivateFieldSet(this, _TreeViewSubTreeNodeElement_activeElementIsLoader, document.activeElement === this.loadingIndicator.closest('[role=treeitem]'), "f");
244
+ // Also check if the include-fragment itself has focus (when it has role="treeitem")
245
+ if (!__classPrivateFieldGet(this, _TreeViewSubTreeNodeElement_activeElementIsLoader, "f") && document.activeElement === this.subTree && __classPrivateFieldGet(this, _TreeViewSubTreeNodeElement_instances, "m", _TreeViewSubTreeNodeElement_isIncludeFragment).call(this)) {
246
+ __classPrivateFieldSet(this, _TreeViewSubTreeNodeElement_activeElementIsLoader, true, "f");
247
+ }
240
248
  this.loadingState = 'success';
241
249
  break;
242
250
  case 'include-fragment-replaced':
@@ -332,6 +340,13 @@ _TreeViewSubTreeNodeElement_update = function _TreeViewSubTreeNodeElement_update
332
340
  if (this.expanded) {
333
341
  if (this.subTree)
334
342
  this.subTree.hidden = false;
343
+ if (__classPrivateFieldGet(this, _TreeViewSubTreeNodeElement_instances, "m", _TreeViewSubTreeNodeElement_isIncludeFragment).call(this)) {
344
+ this.subTree.setAttribute('role', 'treeitem');
345
+ // Ensure the include-fragment can participate in roving tab index
346
+ if (!this.subTree.hasAttribute('tabindex')) {
347
+ this.subTree.setAttribute('tabindex', '-1');
348
+ }
349
+ }
335
350
  this.node.setAttribute('aria-expanded', 'true');
336
351
  this.treeView?.expandAncestorsForNode(this);
337
352
  if (this.iconPair) {
@@ -345,6 +360,11 @@ _TreeViewSubTreeNodeElement_update = function _TreeViewSubTreeNodeElement_update
345
360
  else {
346
361
  if (this.subTree)
347
362
  this.subTree.hidden = true;
363
+ if (__classPrivateFieldGet(this, _TreeViewSubTreeNodeElement_instances, "m", _TreeViewSubTreeNodeElement_isIncludeFragment).call(this)) {
364
+ this.subTree.removeAttribute('role');
365
+ // Remove tabindex when role is removed
366
+ this.subTree.removeAttribute('tabindex');
367
+ }
348
368
  this.node.setAttribute('aria-expanded', 'false');
349
369
  if (this.iconPair) {
350
370
  this.iconPair.showCollapsed();
@@ -375,6 +395,9 @@ _TreeViewSubTreeNodeElement_update = function _TreeViewSubTreeNodeElement_update
375
395
  this.loadingFailureMessage.hidden = true;
376
396
  }
377
397
  };
398
+ _TreeViewSubTreeNodeElement_isIncludeFragment = function _TreeViewSubTreeNodeElement_isIncludeFragment() {
399
+ return this.subTree?.getAttribute('data-target')?.includes('tree-view-sub-tree-node.includeFragment') ?? false;
400
+ };
378
401
  _TreeViewSubTreeNodeElement_checkboxElement_get = function _TreeViewSubTreeNodeElement_checkboxElement_get() {
379
402
  return this.querySelector('.TreeViewItemCheckbox');
380
403
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.50.0",
3
+ "version": "0.50.1-rc.3cbb9623",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -78,14 +78,14 @@
78
78
  "eslint": "^9.10.0",
79
79
  "eslint-plugin-github": "^6.0.0",
80
80
  "glob": "^11.0.2",
81
- "markdownlint-cli2": "^0.19.1",
81
+ "markdownlint-cli2": "^0.20.0",
82
82
  "mocha": "^11.0.1",
83
83
  "playwright": "^1.57.0",
84
84
  "postcss": "^8.4.16",
85
85
  "postcss-cli": "^11.0.0",
86
86
  "postcss-import": "^16.0.0",
87
87
  "postcss-mixins": "^12.1.2",
88
- "postcss-preset-env": "^10.0.2",
88
+ "postcss-preset-env": "^11.1.2",
89
89
  "prettier": "^3.3.2",
90
90
  "rollup": "^2.79.1",
91
91
  "rollup-plugin-terser": "^7.0.2",
@@ -4629,7 +4629,7 @@
4629
4629
  {
4630
4630
  "fully_qualified_name": "Primer::Alpha::Layout",
4631
4631
  "description": "`Layout` provides foundational patterns for responsive pages.\n`Layout` can be used for simple two-column pages, or it can be nested to provide flexible 3-column experiences.\n On smaller screens, `Layout` uses vertically stacked rows to display content.\n\n`Layout` flows as both column, when there's enough horizontal space to render both `Main` and `Sidebar`side-by-side (on a desktop of tablet device, per instance);\nor it flows as a row, when `Main` and `Sidebar` are stacked vertically (e.g. on a mobile device).\n`Layout` should always work in any screen size.",
4632
- "accessibility_docs": "Keyboard navigation follows the markup order. Decide carefully how the focus order should be be by deciding whether\n`main` or `sidebar` comes first in code. The code order wont affect the visual position.",
4632
+ "accessibility_docs": "Keyboard navigation follows the markup order. Decide carefully how the focus order should be be by deciding whether\n`main` or `sidebar` comes first in code. The code order won't affect the visual position.\n\nWhen using `row_placement: :none` on the sidebar, the sidebar content will be hidden at narrow viewports.\nThis may cause WCAG 1.4.10 Reflow failures if the sidebar contains essential content. Only use `:none`\nwhen the sidebar content is non-essential or available elsewhere on the page.",
4633
4633
  "is_form_component": false,
4634
4634
  "is_published": true,
4635
4635
  "requires_js": false,
@@ -4704,7 +4704,7 @@
4704
4704
  "name": "row_placement",
4705
4705
  "type": "Symbol",
4706
4706
  "default": "N/A",
4707
- "description": "Sidebar placement when `Layout` is in row mode. One of `:end`, `:none`, or `:start`."
4707
+ "description": "Sidebar placement when `Layout` is in row mode. One of `:end`, `:none`, or `:start`. **Note:** Using `:none` hides the sidebar at narrow viewports, which may cause WCAG 1.4.10 Reflow issues if the sidebar contains essential content."
4708
4708
  },
4709
4709
  {
4710
4710
  "name": "system_arguments",