@brightspace-ui/core 1.210.0 → 1.210.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/README.md CHANGED
@@ -119,20 +119,23 @@ Note: The axe tests require `prefers-reduced-motion` emulation to be turned on i
119
119
 
120
120
  This repo uses the [@brightspace-ui/visual-diff utility](https://github.com/BrightspaceUI/visual-diff/) to compare current snapshots against a set of golden snapshots stored in source control.
121
121
 
122
- The golden snapshots in source control must be updated by Github Actions. If your PR's code changes result in visual differences, a PR with the new goldens will be automatically opened for you against your branch.
122
+ The golden snapshots in source control must be updated by the [visual-diff GitHub Action](https://github.com/BrightspaceUI/actions/tree/main/visual-diff). If a pull request results in visual differences, a draft pull request with the new goldens will automatically be opened against its branch.
123
123
 
124
- If you'd like to run the tests locally to help troubleshoot or develop new tests, you can use these commands:
124
+ To run the tests locally to help troubleshoot or develop new tests, first install these dependencies:
125
125
 
126
126
  ```shell
127
- # Install dependencies locally
128
- npm install mocha puppeteer @brightspace-ui/visual-diff --no-save
127
+ npm install @brightspace-ui/visual-diff@X mocha@Y puppeteer@Z --no-save
128
+ ```
129
+
130
+ Replace `X`, `Y` and `Z` with [the current versions](https://github.com/BrightspaceUI/actions/tree/main/visual-diff#current-dependency-versions) the action is using.
131
+
132
+ Then run the tests:
129
133
 
134
+ ```shell
130
135
  # run visual-diff tests
131
136
  npx mocha './**/*.visual-diff.js' -t 10000
132
-
133
137
  # subset of visual-diff tests:
134
138
  npx mocha './**/*.visual-diff.js' -t 10000 -g some-pattern
135
-
136
139
  # update visual-diff goldens
137
140
  npx mocha './**/*.visual-diff.js' -t 10000 --golden
138
141
  ```
@@ -394,7 +394,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
394
394
  if (this.opened) {
395
395
  this.close();
396
396
  } else {
397
- this.open(applyFocus);
397
+ this.open(!this.noAutoFocus && applyFocus);
398
398
  }
399
399
  }
400
400
 
@@ -518,11 +518,10 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
518
518
 
519
519
  await this.__position();
520
520
  this._showBackdrop = this._useMobileStyling && this.mobileTray;
521
-
522
521
  if (!this.noAutoFocus && this.__applyFocus) {
523
522
  const focusable = getFirstFocusableDescendant(this);
524
523
  if (focusable) {
525
- // bumping this to the next frame is required to prevent Legacy-Edge from crazily invoking click on the focused element
524
+ // Removing the rAF call can allow infinite focus looping to happen in content using a focus trap
526
525
  requestAnimationFrame(() => focusable.focus());
527
526
  } else {
528
527
  content.setAttribute('tabindex', '-1');
@@ -1014,7 +1013,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
1014
1013
  const content = this.__getContentContainer();
1015
1014
  const focusable = getFirstFocusableDescendant(content);
1016
1015
  if (focusable) {
1017
- // bumping this to the next frame is required to prevent Legacy-Edge from crazily invoking click on the focused element
1016
+ // Removing the rAF call can allow infinite focus looping to happen in content using a focus trap
1018
1017
  requestAnimationFrame(() => focusable.focus());
1019
1018
  } else {
1020
1019
  content.setAttribute('tabindex', '-1');
@@ -112,9 +112,7 @@ class DropdownMenu extends ThemeMixin(DropdownContentMixin(LitElement)) {
112
112
 
113
113
  menu.resize();
114
114
 
115
- if (this.__applyFocus) {
116
- menu.focus();
117
- }
115
+ menu.focus();
118
116
  }
119
117
 
120
118
  _onSelect(e) {
@@ -262,7 +262,7 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
262
262
  this._isHovering = false;
263
263
  this.openDropdown(false);
264
264
  }
265
- } else this.toggleOpen(false);
265
+ } else this.toggleOpen(true);
266
266
  }
267
267
 
268
268
  /* used by open-on-hover option */
@@ -1,4 +1,6 @@
1
- export const MenuItemMixin = superclass => class extends superclass {
1
+
2
+ import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
3
+ export const MenuItemMixin = superclass => class extends FocusVisiblePolyfillMixin(superclass) {
2
4
 
3
5
  static get properties() {
4
6
  return {
@@ -15,9 +15,10 @@ export const menuItemStyles = css`
15
15
  outline: none;
16
16
  width: 100%;
17
17
  }
18
- :host(:focus),
18
+
19
19
  :host(:hover),
20
- :host([first]:focus),
20
+ :host(.focus-visible),
21
+ :host(.focus-visible[first]),
21
22
  :host([first]:hover) {
22
23
  background-color: var(--d2l-menu-background-color-hover);
23
24
  border-bottom: 1px solid var(--d2l-menu-border-color-hover);
@@ -26,7 +27,7 @@ export const menuItemStyles = css`
26
27
  z-index: 2;
27
28
  }
28
29
 
29
- :host([disabled]), :host([disabled]:hover), :host([disabled]:focus) {
30
+ :host([disabled]), :host([disabled]:hover), :host([disabled].focus-visible) {
30
31
  cursor: default;
31
32
  opacity: 0.75;
32
33
  }
@@ -39,7 +40,7 @@ export const menuItemStyles = css`
39
40
  border-top-color: transparent;
40
41
  }
41
42
 
42
- :host([last]:focus),
43
+ :host([last].focus-visible),
43
44
  :host([last]:hover) {
44
45
  border-bottom-color: var(--d2l-menu-border-color-hover);
45
46
  }
@@ -2,6 +2,7 @@ import '../colors/colors.js';
2
2
  import '../icons/icon.js';
3
3
  import './menu-item-return.js';
4
4
  import { css, html, LitElement } from 'lit-element/lit-element.js';
5
+ import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
5
6
  import { HierarchicalViewMixin } from '../hierarchical-view/hierarchical-view-mixin.js';
6
7
  import { ThemeMixin } from '../../mixins/theme-mixin.js';
7
8
 
@@ -20,7 +21,7 @@ const keyCodes = {
20
21
  * @slot - Menu items
21
22
  * @fires d2l-menu-resize - Dispatched when size of menu changes (e.g., when nested menu of a different size is opened)
22
23
  */
23
- class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
24
+ class Menu extends ThemeMixin(HierarchicalViewMixin(FocusVisiblePolyfillMixin(LitElement))) {
24
25
 
25
26
  static get properties() {
26
27
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.210.0",
3
+ "version": "1.210.1",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",
@@ -57,9 +57,10 @@
57
57
  "eslint-plugin-lit": "^1",
58
58
  "eslint-plugin-sort-class-members": "^1",
59
59
  "lit-analyzer": "^1",
60
- "node-sass": "^6",
60
+ "node-sass": "^7",
61
61
  "sinon": "^12",
62
- "stylelint": "^14"
62
+ "stylelint": "^14",
63
+ "web-test-runner-performance": "^0.1.4"
63
64
  },
64
65
  "dependencies": {
65
66
  "@brightspace-ui/intl": "^3",
@@ -1,45 +0,0 @@
1
- import chai from '@open-wc/testing/import-wrappers/chai.js';
2
- import { fixture } from '@open-wc/testing';
3
-
4
- const numComponents = 1000;
5
-
6
- export async function runTest(element) {
7
- return new Promise((resolve) => {
8
-
9
- let total = 0;
10
- let count = 0;
11
- window.d2lPerfTestInProgress = true;
12
- document.body.addEventListener('d2l-component-perf', (e) => {
13
- count++;
14
- total += e.detail.value;
15
- if (count === numComponents) {
16
- const avg = Math.round(total / count);
17
- delete window.d2lPerfTestInProgress;
18
- resolve(avg);
19
- }
20
- });
21
-
22
- for (let i = 0; i < numComponents; i++) {
23
- fixture(element);
24
- }
25
-
26
- });
27
- }
28
-
29
- export const chaiPerf = (_chai, utils) => {
30
-
31
- utils.addMethod(_chai.Assertion.prototype, 'performant', function perfTest(baseline) {
32
- // eslint-disable-next-line no-invalid-this
33
- const fixture = this._obj;
34
- const result = runTest(fixture).then(results => {
35
- new _chai.Assertion(results).to.be.below(baseline);
36
- });
37
- // eslint-disable-next-line no-invalid-this
38
- this.then = result.then.bind(result);
39
- // eslint-disable-next-line no-invalid-this
40
- return this;
41
- });
42
-
43
- };
44
-
45
- chai.use(chaiPerf);