@brightspace-ui/core 3.251.0 → 3.252.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.
@@ -40,11 +40,16 @@ const pointerRotatedLength = Math.SQRT2 * parseFloat(pointerLength);
40
40
 
41
41
  export const isPopoverSupported = ('popover' in HTMLElement.prototype);
42
42
 
43
- const getScrollbarWidth = () => {
44
- const width = window.innerWidth - document.documentElement.clientWidth;
45
- if (width > 0) return width + 1; // 16 when present, but can be 0 even if visible (ex. MacOS depending on settings)
46
- else return 0;
47
- };
43
+ const SCROLLBAR_WIDTH = (() => {
44
+ const div = document.createElement('div');
45
+ div.style.overflow = 'scroll';
46
+ div.style.position = 'fixed';
47
+ div.style.top = '-99999px';
48
+ document.documentElement.appendChild(div);
49
+ const width = div.offsetWidth - div.clientWidth;
50
+ document.documentElement.removeChild(div);
51
+ return width && width + 1;
52
+ })(); // ~16 when present, but can be 0 even if invisible (e.g. macOS depending on settings)
48
53
 
49
54
  export const PopoverMixin = superclass => class extends superclass {
50
55
 
@@ -482,6 +487,10 @@ export const PopoverMixin = superclass => class extends superclass {
482
487
  this._contentHeight = this._maxHeight !== null && availableHeight > this._maxHeight
483
488
  ? this._maxHeight - 2 : availableHeight;
484
489
 
490
+ if (height === (this._maxHeight ?? 0) || content.clientHeight >= availableHeight) {
491
+ this._width = this._width + SCROLLBAR_WIDTH;
492
+ }
493
+
485
494
  // ensure the content height has updated when the __toggleScrollStyles event handler runs
486
495
  await this.updateComplete;
487
496
  }
@@ -493,7 +502,7 @@ export const PopoverMixin = superclass => class extends superclass {
493
502
 
494
503
  };
495
504
 
496
- const scrollWidth = content.scrollWidth;
505
+ const scrollWidth = Math.ceil(content.getBoundingClientRect().width);
497
506
  const availableWidth = window.innerWidth - 40;
498
507
 
499
508
  this._width = (availableWidth > scrollWidth ? scrollWidth : availableWidth);
@@ -823,7 +832,7 @@ export const PopoverMixin = superclass => class extends superclass {
823
832
  }
824
833
 
825
834
  // if no width property set, automatically size to maximum width
826
- let widthOverride = this._width ? this._width : maxWidthOverride;
835
+ let widthOverride = this._width || maxWidthOverride;
827
836
  // ensure width is between minWidth and maxWidth
828
837
  if (widthOverride && maxWidthOverride && widthOverride > (maxWidthOverride - 20)) widthOverride = maxWidthOverride - 20;
829
838
  if (widthOverride && minWidthOverride && widthOverride < (minWidthOverride - 20)) widthOverride = minWidthOverride - 20;
@@ -910,16 +919,16 @@ export const PopoverMixin = superclass => class extends superclass {
910
919
  }
911
920
  } else {
912
921
  if (this._preferredPosition.span === positionSpans.end) {
913
- position.right = window.innerWidth - openerRect.right + xAdjustment - getScrollbarWidth();
922
+ position.right = window.innerWidth - openerRect.right + xAdjustment - SCROLLBAR_WIDTH;
914
923
  } else {
915
- position.left = (window.innerWidth - openerRect.left - xAdjustment - getScrollbarWidth()) * -1;
924
+ position.left = (window.innerWidth - openerRect.left - xAdjustment - SCROLLBAR_WIDTH) * -1;
916
925
  }
917
926
  }
918
927
  } else {
919
928
  if (!this._rtl) {
920
929
  position.left = openerRect.left + ((openerRect.width - pointerRect.width) / 2);
921
930
  } else {
922
- position.right = window.innerWidth - openerRect.left - ((openerRect.width + pointerRect.width) / 2) - getScrollbarWidth();
931
+ position.right = window.innerWidth - openerRect.left - ((openerRect.width + pointerRect.width) / 2) - SCROLLBAR_WIDTH;
923
932
  }
924
933
  }
925
934
 
@@ -937,13 +946,13 @@ export const PopoverMixin = superclass => class extends superclass {
937
946
  if (!this._rtl) {
938
947
  position.right = (openerRect.left - this._offset + 7) * -1; // 7 minor adjustment to position pointer at edge of content
939
948
  } else {
940
- position.left = (window.innerWidth - openerRect.right + 7 - this._offset - getScrollbarWidth()) * -1; // 7 minor adjustment to position pointer at edge of content
949
+ position.left = (window.innerWidth - openerRect.right + 7 - this._offset - SCROLLBAR_WIDTH) * -1; // 7 minor adjustment to position pointer at edge of content
941
950
  }
942
951
  } else {
943
952
  if (!this._rtl) {
944
953
  position.left = openerRect.left + openerRect.width + this._offset - 7; // 7 minor adjustment to position pointer at edge of content
945
954
  } else {
946
- position.right = window.innerWidth - openerRect.left - 7 + this._offset - getScrollbarWidth(); // 7 minor adjustment to position pointer at edge of content
955
+ position.right = window.innerWidth - openerRect.left - 7 + this._offset - SCROLLBAR_WIDTH; // 7 minor adjustment to position pointer at edge of content
947
956
  }
948
957
  }
949
958
 
@@ -962,7 +971,7 @@ export const PopoverMixin = superclass => class extends superclass {
962
971
  if (!this._rtl) {
963
972
  position.left = openerRect.left + xAdjustment;
964
973
  } else {
965
- position.right = window.innerWidth - openerRect.left - openerRect.width + xAdjustment - getScrollbarWidth();
974
+ position.right = window.innerWidth - openerRect.left - openerRect.width + xAdjustment - SCROLLBAR_WIDTH;
966
975
  }
967
976
  }
968
977
 
@@ -983,13 +992,13 @@ export const PopoverMixin = superclass => class extends superclass {
983
992
  if (!this._rtl) {
984
993
  position.right = (openerRect.left - this._offset) * -1;
985
994
  } else {
986
- position.left = (window.innerWidth - openerRect.right - this._offset - getScrollbarWidth()) * -1;
995
+ position.left = (window.innerWidth - openerRect.right - this._offset - SCROLLBAR_WIDTH) * -1;
987
996
  }
988
997
  } else {
989
998
  if (!this._rtl) {
990
999
  position.left = openerRect.left + openerRect.width + this._offset;
991
1000
  } else {
992
- position.right = window.innerWidth - openerRect.left + this._offset - getScrollbarWidth();
1001
+ position.right = window.innerWidth - openerRect.left + this._offset - SCROLLBAR_WIDTH;
993
1002
  }
994
1003
  }
995
1004
 
@@ -1082,7 +1091,7 @@ export const PopoverMixin = superclass => class extends superclass {
1082
1091
  const widthStyle = {
1083
1092
  maxWidth: this._maxWidth ? `${this._maxWidth}px` : undefined,
1084
1093
  minWidth: this._minWidth ? `${this._minWidth}px` : undefined,
1085
- width: this._width ? `${this._width + 3}px` : undefined // add 3 to content to account for possible rounding and also scrollWidth does not include border
1094
+ width: this._width ? `${this._width + 2}px` : undefined
1086
1095
  };
1087
1096
 
1088
1097
  const contentStyle = {
@@ -75,6 +75,7 @@ class Progress extends LocalizeCoreElement(LitElement) {
75
75
  appearance: none;
76
76
  background-color: var(--d2l-color-gypsum);
77
77
  box-shadow: inset 0 2px var(--d2l-color-mica);
78
+ overflow: hidden;
78
79
  width: 100%;
79
80
  }
80
81
  .bar {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.251.0",
3
+ "version": "3.252.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",