@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 +9 -6
- package/components/dropdown/dropdown-content-mixin.js +3 -4
- package/components/dropdown/dropdown-menu.js +1 -3
- package/components/dropdown/dropdown-opener-mixin.js +1 -1
- package/components/menu/menu-item-mixin.js +3 -1
- package/components/menu/menu-item-styles.js +5 -4
- package/components/menu/menu.js +2 -1
- package/package.json +4 -3
- package/tools/perf-test-helper.js +0 -45
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
|
|
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
|
-
|
|
124
|
+
To run the tests locally to help troubleshoot or develop new tests, first install these dependencies:
|
|
125
125
|
|
|
126
126
|
```shell
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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');
|
|
@@ -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(
|
|
265
|
+
} else this.toggleOpen(true);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
/* used by open-on-hover option */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
18
|
+
|
|
19
19
|
:host(:hover),
|
|
20
|
-
:host(
|
|
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]
|
|
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]
|
|
43
|
+
:host([last].focus-visible),
|
|
43
44
|
:host([last]:hover) {
|
|
44
45
|
border-bottom-color: var(--d2l-menu-border-color-hover);
|
|
45
46
|
}
|
package/components/menu/menu.js
CHANGED
|
@@ -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.
|
|
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": "^
|
|
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);
|