@brightspace-ui/core 2.142.0 → 2.142.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.
@@ -106,14 +106,10 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
106
106
  button::-moz-focus-inner {
107
107
  border: 0;
108
108
  }
109
- button[disabled]:hover,
110
- button[disabled]:focus,
111
- :host([active]) button[disabled] {
112
- background-color: var(--d2l-button-icon-background-color);
113
- }
114
- button:hover,
115
- button:focus,
116
- :host([active]) button {
109
+
110
+ button:hover:not([disabled]),
111
+ button:focus:not([disabled]),
112
+ :host([active]) button:not([disabled]) {
117
113
  --d2l-icon-fill-color: var(--d2l-button-icon-fill-color-hover, var(--d2l-color-tungsten));
118
114
  background-color: var(--d2l-button-icon-background-color-hover);
119
115
  }
@@ -1,12 +1,14 @@
1
1
  import '../colors/colors.js';
2
2
  import '../../helpers/requestIdleCallback.js';
3
3
  import { css, html, LitElement } from 'lit';
4
- import { getBoundingAncestor, getComposedParent } from '../../helpers/dom.js';
4
+ import { getBoundingAncestor, getComposedParent, isComposedAncestor } from '../../helpers/dom.js';
5
+ import { getComposedActiveElement } from '../../helpers/focus.js';
5
6
  import { getLegacyOffsetParent } from '../../helpers/offsetParent-legacy.js';
6
7
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
7
8
  import { styleMap } from 'lit/directives/style-map.js';
8
9
 
9
10
  const mediaQueryList = window.matchMedia('(max-height: 500px)');
11
+ const MINIMUM_TARGET_SIZE = 24;
10
12
 
11
13
  /**
12
14
  * A wrapper component to display floating workflow buttons. When the normal position of the workflow buttons is below the bottom edge of the viewport, they will dock at the bottom edge. When the normal position becomes visible, they will undock.
@@ -113,6 +115,7 @@ class FloatingButtons extends RtlMixin(LitElement) {
113
115
  this._isIntersecting = false;
114
116
  this._recalculateFloating = this._recalculateFloating.bind(this);
115
117
  this._testElem = null;
118
+ this._scrollIfFloatObsuringFocus = this._scrollIfFloatObsuringFocus.bind(this);
116
119
  }
117
120
 
118
121
  connectedCallback() {
@@ -144,6 +147,8 @@ class FloatingButtons extends RtlMixin(LitElement) {
144
147
  }
145
148
  }, { timeout: 5000 });
146
149
 
150
+ document.addEventListener('focusin', this._scrollIfFloatObsuringFocus);
151
+
147
152
  }
148
153
 
149
154
  disconnectedCallback() {
@@ -154,6 +159,7 @@ class FloatingButtons extends RtlMixin(LitElement) {
154
159
  this._testElem.parentNode.removeChild(this._testElem);
155
160
  this._testElem = null;
156
161
  }
162
+ document.removeEventListener('focusin', this._scrollIfFloatObsuringFocus);
157
163
  }
158
164
 
159
165
  render() {
@@ -270,6 +276,27 @@ class FloatingButtons extends RtlMixin(LitElement) {
270
276
  });
271
277
  }
272
278
 
279
+ _scrollIfFloatObsuringFocus() {
280
+
281
+ if (!this._floating) return;
282
+
283
+ const currentFocusedItem = getComposedActiveElement();
284
+ if (isComposedAncestor(this, currentFocusedItem)) return;
285
+
286
+ const { y: focusedY, height: focusedHeight } = currentFocusedItem.getBoundingClientRect();
287
+ const { y: floatingY, height: floatingHeight } = this.shadowRoot.querySelector('.d2l-floating-buttons-container').getBoundingClientRect();
288
+ if (focusedY === 0 || floatingY === 0) return;
289
+
290
+ const isObscuring = (floatingY - focusedY) < Math.min(MINIMUM_TARGET_SIZE, focusedHeight);
291
+ if (!isObscuring) return;
292
+
293
+ const prev = currentFocusedItem.style.scrollMarginBottom;
294
+ currentFocusedItem.style.scrollMarginBottom = `${floatingHeight}px`;
295
+ currentFocusedItem.scrollIntoView(false);
296
+ currentFocusedItem.style.scrollMarginBottom = prev;
297
+
298
+ }
299
+
273
300
  }
274
301
 
275
302
  customElements.define('d2l-floating-buttons', FloatingButtons);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.142.0",
3
+ "version": "2.142.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",