@brightspace-ui/core 3.126.2 → 3.126.4
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/components/filter/filter.js +4 -12
- package/components/inputs/input-search.js +11 -0
- package/components/inputs/input-select-styles.js +60 -53
- package/components/inputs/input-text.js +8 -0
- package/components/menu/demo/menu.html +34 -0
- package/components/menu/menu-item-mixin.js +1 -0
- package/components/menu/menu.js +19 -6
- package/package.json +1 -1
@@ -30,7 +30,6 @@ import { formatNumber } from '@brightspace-ui/intl/lib/number.js';
|
|
30
30
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
31
31
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
32
32
|
import { offscreenStyles } from '../offscreen/offscreen.js';
|
33
|
-
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
34
33
|
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
35
34
|
import { SubscriberRegistryController } from '../../controllers/subscriber/subscriberControllers.js';
|
36
35
|
|
@@ -237,6 +236,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
|
|
237
236
|
this._displayKeyboardTooltip = false;
|
238
237
|
this._minWidth = 285;
|
239
238
|
this._openedDimensions = [];
|
239
|
+
this._resized = false;
|
240
240
|
this._totalAppliedCount = 0;
|
241
241
|
|
242
242
|
this._activeFilters = null;
|
@@ -351,16 +351,6 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
|
|
351
351
|
super.update(changedProperties);
|
352
352
|
}
|
353
353
|
|
354
|
-
updated(changedProperties) {
|
355
|
-
super.updated(changedProperties);
|
356
|
-
const search = this.shadowRoot.querySelector('d2l-input-search');
|
357
|
-
if (search) {
|
358
|
-
if (this.#resizeObserver) this.#resizeObserver.disconnect();
|
359
|
-
this.#resizeObserver = new ResizeObserver(() => requestAnimationFrame(() => this.#handleSearchResize()));
|
360
|
-
this.#resizeObserver.observe(search);
|
361
|
-
}
|
362
|
-
}
|
363
|
-
|
364
354
|
requestFilterClearAll() {
|
365
355
|
this._handleClearAll();
|
366
356
|
}
|
@@ -455,6 +445,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
|
|
455
445
|
const search = dimension.searchType === 'none' ? nothing : html`
|
456
446
|
<d2l-input-search
|
457
447
|
@d2l-input-search-searched="${this._handleSearch}"
|
448
|
+
@d2l-input-search-layout-updated="${this.#handleSearchLayoutUpdated}"
|
458
449
|
?disabled="${this._isDimensionEmpty(dimension)}"
|
459
450
|
label="${this.localize('components.input-search.search')}"
|
460
451
|
value="${ifDefined(dimension.searchValue)}">
|
@@ -684,6 +675,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
|
|
684
675
|
this._changeEventsToDispatch = new Map();
|
685
676
|
clearTimeout(this._changeEventTimeout);
|
686
677
|
this._activeFiltersSubscribers.updateSubscribers();
|
678
|
+
this.#handleSearchLayoutUpdated(); // in order to update dropdown position if count-badge size changes pointer position
|
687
679
|
}
|
688
680
|
|
689
681
|
_dispatchChangeEventValueDataChange(dimension, value, valueKey) {
|
@@ -1153,7 +1145,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
|
|
1153
1145
|
}
|
1154
1146
|
}
|
1155
1147
|
|
1156
|
-
#
|
1148
|
+
#handleSearchLayoutUpdated() {
|
1157
1149
|
const content = this.shadowRoot.querySelector(`.${FILTER_CONTENT_CLASS}`);
|
1158
1150
|
content.resize();
|
1159
1151
|
}
|
@@ -132,6 +132,7 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
|
|
132
132
|
<d2l-input-text
|
133
133
|
label="${ifDefined(this.label)}"
|
134
134
|
label-hidden
|
135
|
+
@d2l-input-text-layout-updated="${this.#handleLayoutUpdated}"
|
135
136
|
description="${this.description}"
|
136
137
|
?disabled="${this.disabled}"
|
137
138
|
@input="${this._handleInput}"
|
@@ -213,5 +214,15 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
|
|
213
214
|
return (oldVal !== val);
|
214
215
|
}
|
215
216
|
|
217
|
+
#handleLayoutUpdated() {
|
218
|
+
requestAnimationFrame(() => {
|
219
|
+
/** @ignore */
|
220
|
+
this.dispatchEvent(new CustomEvent(
|
221
|
+
'd2l-input-search-layout-updated',
|
222
|
+
{ bubbles: false, composed: false }
|
223
|
+
));
|
224
|
+
});
|
225
|
+
}
|
226
|
+
|
216
227
|
}
|
217
228
|
customElements.define('d2l-input-search', InputSearch);
|
@@ -1,18 +1,23 @@
|
|
1
1
|
import '../colors/colors.js';
|
2
|
-
import { css } from 'lit';
|
2
|
+
import { css, unsafeCSS } from 'lit';
|
3
|
+
import { getFocusPseudoClass } from '../../helpers/focus.js';
|
4
|
+
|
5
|
+
const focusClass = unsafeCSS(getFocusPseudoClass());
|
3
6
|
|
4
7
|
export const selectStyles = css`
|
5
8
|
.d2l-input-select {
|
6
9
|
-webkit-appearance: none;
|
7
10
|
-moz-appearance: none;
|
8
11
|
appearance: none;
|
12
|
+
background-color: #ffffff;
|
13
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDExIDciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZD0iTTEgMmw0LjUgNE0xMCAyTDUuNSA2IiBzdHJva2U9IiM1NjVBNUMiIHN0cm9rZS13aWR0aD0iMiIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz4KPC9zdmc+");
|
9
14
|
background-origin: border-box;
|
10
15
|
background-position: center right 17px;
|
11
16
|
background-repeat: no-repeat;
|
12
17
|
background-size: 11px 7px;
|
18
|
+
border: none;
|
13
19
|
border-radius: 0.3rem;
|
14
|
-
|
15
|
-
box-sizing: border-box;
|
20
|
+
box-shadow: inset 0 2px 0 1px rgba(177, 185, 190, 0.2); /* corundum */
|
16
21
|
color: var(--d2l-color-ferrite);
|
17
22
|
display: inline-block;
|
18
23
|
font-family: inherit;
|
@@ -23,53 +28,32 @@ export const selectStyles = css`
|
|
23
28
|
line-height: 1.2rem;
|
24
29
|
margin: 0;
|
25
30
|
max-height: calc(2rem + 2px);
|
31
|
+
outline: 1px solid var(--d2l-color-galena);
|
32
|
+
outline-offset: -1px;
|
33
|
+
padding-block: calc(0.4rem + 1px);
|
34
|
+
padding-inline: calc(0.75rem + 1px) calc(2px + 0.8rem + 1px + 11px + 16px + 1px);
|
26
35
|
vertical-align: middle;
|
27
36
|
}
|
28
37
|
:host([dir="rtl"]) .d2l-input-select {
|
29
38
|
background-position: center left 17px;
|
30
39
|
}
|
31
|
-
|
32
|
-
.d2l-input-select:hover
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
padding: 0.4rem 0.75rem;
|
38
|
-
}
|
39
|
-
.d2l-input-select,
|
40
|
-
.d2l-input-select:disabled,
|
41
|
-
.d2l-input-select:hover:disabled,
|
42
|
-
.d2l-input-select:focus:disabled {
|
43
|
-
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDExIDciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZD0iTTEgMmw0LjUgNE0xMCAyTDUuNSA2IiBzdHJva2U9IiM1NjVBNUMiIHN0cm9rZS13aWR0aD0iMiIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz4KPC9zdmc+");
|
44
|
-
padding-right: calc(2px + 0.8rem + 1px + 11px + 16px);
|
45
|
-
}
|
46
|
-
:host([dir="rtl"]) .d2l-input-select,
|
47
|
-
:host([dir="rtl"]) .d2l-input-select:disabled,
|
48
|
-
:host([dir="rtl"]) .d2l-input-select:hover:disabled,
|
49
|
-
:host([dir="rtl"]) .d2l-input-select:focus:disabled {
|
50
|
-
padding-left: calc(2px + 0.8rem + 1px + 11px + 16px);
|
51
|
-
padding-right: 0.75rem;
|
52
|
-
}
|
53
|
-
.d2l-input-select:hover,
|
54
|
-
.d2l-input-select:focus {
|
55
|
-
border-color: var(--d2l-color-celestine);
|
56
|
-
border-width: 2px;
|
57
|
-
outline-style: none; /* Safari */
|
58
|
-
outline-width: 0;
|
59
|
-
padding: calc(0.4rem - 1px) calc(0.75rem - 1px);
|
60
|
-
padding-right: calc(2px + 0.8rem + 1px + 11px + 16px - 1px);
|
61
|
-
}
|
62
|
-
:host([dir="rtl"]) .d2l-input-select:hover,
|
63
|
-
:host([dir="rtl"]) .d2l-input-select:focus {
|
64
|
-
padding-left: calc(2px + 0.8rem + 1px + 11px + 16px - 1px);
|
65
|
-
padding-right: calc(0.75rem - 1px);
|
40
|
+
|
41
|
+
.d2l-input-select:not([disabled]):hover,
|
42
|
+
.d2l-input-select:not([disabled]):${focusClass} {
|
43
|
+
box-shadow: inset 0 2px 0 2px rgba(177, 185, 190, 0.2); /* corundum */
|
44
|
+
outline: 2px solid var(--d2l-color-celestine);
|
45
|
+
outline-offset: -2px;
|
66
46
|
}
|
67
47
|
.d2l-input-select[aria-invalid="true"] {
|
68
48
|
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDExIDciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZD0iTTEgMmw0LjUgNE0xMCAyTDUuNSA2IiBzdHJva2U9IiM1NjVBNUMiIHN0cm9rZS13aWR0aD0iMiIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz4KPC9zdmc+"), url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE4IDE4Ij4KICA8cGF0aCBmaWxsPSIjY2QyMDI2IiBkPSJNMTcuNzkgMTUuMTFsLTctMTRhMiAyIDAgMCAwLTMuNTggMGwtNyAxNGExLjk3NSAxLjk3NSAwIDAgMCAuMDkgMS45NEEyIDIgMCAwIDAgMiAxOGgxNGExLjk5NCAxLjk5NCAwIDAgMCAxLjctLjk1IDEuOTY3IDEuOTY3IDAgMCAwIC4wOS0xLjk0ek05IDE2YTEuNSAxLjUgMCAxIDEgMS41LTEuNUExLjUgMS41IDAgMCAxIDkgMTZ6bS45OC00LjgwNmExIDEgMCAwIDEtMS45NiAwbC0uOTktNUExIDEgMCAwIDEgOC4wMSA1aDEuOTgzYTEgMSAwIDAgMSAuOTggMS4xOTR6Ii8+Cjwvc3ZnPgo=");
|
69
49
|
background-position: center right 17px, center right calc(1px + 11px + 17px);
|
70
50
|
background-repeat: no-repeat, no-repeat;
|
71
51
|
background-size: 11px 7px, 0.8rem 0.8rem;
|
72
|
-
|
52
|
+
}
|
53
|
+
.d2l-input-select[aria-invalid="true"],
|
54
|
+
.d2l-input-select[aria-invalid="true"]:${focusClass},
|
55
|
+
.d2l-input-select[aria-invalid="true"]:hover {
|
56
|
+
outline-color: var(--d2l-color-cinnabar);
|
73
57
|
}
|
74
58
|
:host([dir="rtl"]) .d2l-input-select[aria-invalid="true"] {
|
75
59
|
background-position: center left 17px, center left calc(1px + 11px + 17px);
|
@@ -77,19 +61,42 @@ export const selectStyles = css`
|
|
77
61
|
.d2l-input-select:disabled {
|
78
62
|
opacity: 0.5;
|
79
63
|
}
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
64
|
+
|
65
|
+
@media (prefers-contrast: more) {
|
66
|
+
.d2l-input-select {
|
67
|
+
appearance: auto;
|
68
|
+
background-color: Field;
|
69
|
+
background-image: none;
|
70
|
+
border: none;
|
71
|
+
border-inline-end: 0.75rem solid transparent;
|
72
|
+
box-shadow: none;
|
73
|
+
color: FieldText;
|
74
|
+
forced-color-adjust: none;
|
75
|
+
height: 2rem;
|
76
|
+
outline: 1px solid FieldText;
|
77
|
+
padding-inline: 0.6rem 16px;
|
78
|
+
}
|
79
|
+
|
80
|
+
.d2l-input-select:not([disabled]):${focusClass},
|
81
|
+
.d2l-input-select:not([disabled]):hover {
|
82
|
+
box-shadow: none;
|
83
|
+
outline: 2px solid Highlight;
|
84
|
+
}
|
85
|
+
|
86
|
+
.d2l-input-select[aria-invalid="true"] {
|
87
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE4IDE4Ij4KICA8cGF0aCBmaWxsPSIjY2QyMDI2IiBkPSJNMTcuNzkgMTUuMTFsLTctMTRhMiAyIDAgMCAwLTMuNTggMGwtNyAxNGExLjk3NSAxLjk3NSAwIDAgMCAuMDkgMS45NEEyIDIgMCAwIDAgMiAxOGgxNGExLjk5NCAxLjk5NCAwIDAgMCAxLjctLjk1IDEuOTY3IDEuOTY3IDAgMCAwIC4wOS0xLjk0ek05IDE2YTEuNSAxLjUgMCAxIDEgMS41LTEuNUExLjUgMS41IDAgMCAxIDkgMTZ6bS45OC00LjgwNmExIDEgMCAwIDEtMS45NiAwbC0uOTktNUExIDEgMCAwIDEgOC4wMSA1aDEuOTgzYTEgMSAwIDAgMSAuOTggMS4xOTR6Ii8+Cjwvc3ZnPgo=");
|
88
|
+
background-position: center right calc(1px + 11px + 17px);
|
89
|
+
background-repeat: no-repeat;
|
90
|
+
background-size: 0.8rem 0.8rem;
|
91
|
+
}
|
92
|
+
|
93
|
+
.d2l-input-select[aria-invalid="true"],
|
94
|
+
.d2l-input-select[aria-invalid="true"]:${focusClass},
|
95
|
+
.d2l-input-select[aria-invalid="true"]:hover {
|
96
|
+
outline-color: var(--d2l-color-cinnabar);
|
97
|
+
}
|
98
|
+
:host([dir="rtl"]) .d2l-input-select[aria-invalid="true"] {
|
99
|
+
background-position: center left calc(1px + 11px + 17px);
|
100
|
+
}
|
94
101
|
}
|
95
102
|
`;
|
@@ -678,6 +678,14 @@ class InputText extends InputInlineHelpMixin(PropertyRequiredMixin(FocusMixin(La
|
|
678
678
|
this._lastSlotWidth = 0;
|
679
679
|
}
|
680
680
|
|
681
|
+
requestAnimationFrame(() => {
|
682
|
+
/** @ignore */
|
683
|
+
this.dispatchEvent(new CustomEvent(
|
684
|
+
'd2l-input-text-layout-updated',
|
685
|
+
{ bubbles: false, composed: false }
|
686
|
+
));
|
687
|
+
});
|
688
|
+
|
681
689
|
}
|
682
690
|
|
683
691
|
}
|
@@ -17,6 +17,40 @@
|
|
17
17
|
<body unresolved>
|
18
18
|
|
19
19
|
<d2l-demo-page page-title="d2l-menu">
|
20
|
+
<h2>Basic Menu (demo of focus bug)</h2>
|
21
|
+
<d2l-demo-snippet>
|
22
|
+
<template>
|
23
|
+
<div role="menu">
|
24
|
+
<div role="menuitem" tabindex="0">
|
25
|
+
<span>Menu Item 1</span>
|
26
|
+
</div><div role="menuitem" tabindex="-1">
|
27
|
+
<span>Menu Item 2</span>
|
28
|
+
</div><div role="menuitem" tabindex="-1">
|
29
|
+
<span>Menu Item 3</span>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<script>
|
33
|
+
const menu = document.querySelector('div[role="menu"]');
|
34
|
+
const menuItems = menu.querySelectorAll('div[role="menuitem"]');
|
35
|
+
|
36
|
+
menuItems.forEach(item => {
|
37
|
+
item.addEventListener('keydown', (e) => {
|
38
|
+
if (e.keyCode === 40 || e.keyCode === 38) {
|
39
|
+
// prevent scrolling when up/down arrows pressed
|
40
|
+
e.preventDefault();
|
41
|
+
e.stopPropagation();
|
42
|
+
if (e.keyCode === 40) {
|
43
|
+
if (item.nextSibling) item.nextSibling.focus();
|
44
|
+
} else if (e.keyCode === 38) {
|
45
|
+
if (item.previousSibling) item.previousSibling.focus();
|
46
|
+
}
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
});
|
50
|
+
});
|
51
|
+
</script>
|
52
|
+
</template>
|
53
|
+
</d2l-demo-snippet>
|
20
54
|
|
21
55
|
<h2>Menu</h2>
|
22
56
|
|
package/components/menu/menu.js
CHANGED
@@ -102,6 +102,7 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
|
|
102
102
|
this.addEventListener('d2l-menu-item-visibility-change', this._onMenuItemsChanged);
|
103
103
|
this.addEventListener('keydown', this._onKeyDown);
|
104
104
|
this.addEventListener('keypress', this._onKeyPress);
|
105
|
+
this.addEventListener('focusout', this._onFocusOut);
|
105
106
|
|
106
107
|
this._labelChanged();
|
107
108
|
|
@@ -175,28 +176,33 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
|
|
175
176
|
|
176
177
|
_focusFirst() {
|
177
178
|
const item = this._tryGetNextFocusable();
|
178
|
-
if (item)
|
179
|
+
if (item) this._focusItem(item);
|
180
|
+
}
|
181
|
+
|
182
|
+
_focusItem(item) {
|
183
|
+
item.setAttribute('tabindex', '0');
|
184
|
+
item.focus();
|
179
185
|
}
|
180
186
|
|
181
187
|
_focusLast() {
|
182
188
|
const item = this._tryGetPreviousFocusable();
|
183
|
-
if (item)
|
189
|
+
if (item) this._focusItem(item);
|
184
190
|
}
|
185
191
|
|
186
192
|
_focusNext(item) {
|
187
193
|
item = this._tryGetNextFocusable(item);
|
188
|
-
item ?
|
194
|
+
item ? this._focusItem(item) : this._focusFirst();
|
189
195
|
}
|
190
196
|
|
191
197
|
_focusPrevious(item) {
|
192
198
|
item = this._tryGetPreviousFocusable(item);
|
193
|
-
item ?
|
199
|
+
item ? this._focusItem(item) : this._focusLast();
|
194
200
|
}
|
195
201
|
|
196
202
|
_focusSelected() {
|
197
203
|
const selected = this.querySelector('[selected]');
|
198
204
|
if (selected) {
|
199
|
-
|
205
|
+
this._focusItem(selected);
|
200
206
|
} else {
|
201
207
|
this._focusFirst();
|
202
208
|
}
|
@@ -260,6 +266,13 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
|
|
260
266
|
if (returnItem) returnItem.setAttribute('text', this.label);
|
261
267
|
}
|
262
268
|
|
269
|
+
_onFocusOut(e) {
|
270
|
+
e.stopPropagation();
|
271
|
+
const isMenuItem = e.target.role === 'menuitem' || e.target.role === 'menuitemcheckbox' || e.target.role === 'menuitemradio';
|
272
|
+
if (!isMenuItem || e.target.hasAttribute('first') || e.target.hasChildView) return;
|
273
|
+
e.target.setAttribute('tabindex', '-1');
|
274
|
+
}
|
275
|
+
|
263
276
|
_onKeyDown(e) {
|
264
277
|
const rootTarget = e.composedPath()[0];
|
265
278
|
if (this._items.indexOf(rootTarget) === -1) return;
|
@@ -321,7 +334,7 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
|
|
321
334
|
while (itemIndex !== targetItemIndex) {
|
322
335
|
const item = focusableItems[itemIndex];
|
323
336
|
if (startsWith(item, searchChar)) {
|
324
|
-
|
337
|
+
this._focusItem(item);
|
325
338
|
return;
|
326
339
|
}
|
327
340
|
itemIndex = getNextOrFirstIndex(itemIndex);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.126.
|
3
|
+
"version": "3.126.4",
|
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",
|