@trudb/tru-common-lib 0.0.523 → 0.0.525

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.
@@ -2538,6 +2538,12 @@ class TruMatSelectPanel {
2538
2538
  if (this.documentMouseUpEventFn)
2539
2539
  this.documentMouseUpEventFn();
2540
2540
  };
2541
+ this.getTextWidth = (element, text) => {
2542
+ const canvas = document.createElement('canvas');
2543
+ const context = canvas.getContext('2d');
2544
+ context.font = getComputedStyle(element).font;
2545
+ return context.measureText(text).width;
2546
+ };
2541
2547
  }
2542
2548
  ngOnInit() {
2543
2549
  this.select.openedChange.subscribe(isOpen => {
@@ -2552,11 +2558,11 @@ class TruMatSelectPanel {
2552
2558
  let optionSpans = panelElement.querySelectorAll('span');
2553
2559
  let maxWidth = 0;
2554
2560
  optionSpans.forEach((optionSpan) => {
2555
- let currentWidth = parseInt(optionSpan.width, 10);
2561
+ let currentWidth = this.getTextWidth(optionSpan, optionSpan.innerText);
2556
2562
  if (currentWidth > maxWidth)
2557
2563
  maxWidth = currentWidth;
2558
2564
  });
2559
- panelParentElement.style.minWidth = (maxWidth + 60) + 'px';
2565
+ panelParentElement.style.minWidth = (maxWidth + 85) + 'px';
2560
2566
  this.documentMouseUpEventFn = this.renderer.listen(document, 'mouseup', (event) => {
2561
2567
  if (event.target !== this.select.panel.nativeElement && event.button !== 2) {
2562
2568
  this.removeListeners();