cx 23.4.4 → 23.5.0

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.
@@ -42,6 +42,7 @@ import { StaticText } from "../../ui/StaticText";
42
42
  import { unfocusElement } from "../../ui/FocusManager";
43
43
  import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
44
44
  import { Container } from "../../ui/Container";
45
+ import { findFirstChild } from "../../util/DOM";
45
46
 
46
47
  export class Grid extends Container {
47
48
  declareData(...args) {
@@ -510,13 +511,16 @@ export class Grid extends Container {
510
511
  onClick={(e) => {
511
512
  e.stopPropagation();
512
513
  }}
514
+ data-unique-col-id={hdwidget.uniqueColumnId}
513
515
  onMouseDown={(e) => {
514
516
  if (e.buttons != 1) return;
515
517
  let resizeOverlayEl = document.createElement("div");
516
- let headerCell = e.target.parentElement;
517
- if (forPreviousColumn) headerCell = headerCell.previousSibling;
518
+
519
+ let headerTBody = e.target.parentElement.parentElement.parentElement;
520
+ let uniqueColId = e.currentTarget.dataset.uniqueColId;
518
521
 
519
- let scrollAreaEl = headerCell.parentElement.parentElement.parentElement.parentElement;
522
+ let headerCell = findFirstChild(headerTBody, el => el.tagName == 'TH' && el.dataset?.uniqueColId == uniqueColId);
523
+ let scrollAreaEl = headerTBody.parentElement.parentElement;
520
524
  let gridEl = scrollAreaEl.parentElement;
521
525
  let initialWidth = headerCell.offsetWidth;
522
526
  let initialPosition = getCursorPos(e);
@@ -640,15 +644,17 @@ export class Grid extends Container {
640
644
  }
641
645
  }
642
646
 
647
+ let uniqueColumnId = header.data.colSpan > 1 ? null : hdwidget.uniqueColumnId;
648
+
643
649
  style = header.data.style;
644
650
  let customWidth =
645
651
  header.data.width ||
646
- instance.state.colWidth[hdwidget.uniqueColumnId] ||
652
+ instance.state.colWidth[uniqueColumnId] ||
647
653
  header.data.defaultWidth ||
648
- instance.state.lockedColWidth[hdwidget.uniqueColumnId];
654
+ instance.state.lockedColWidth[uniqueColumnId];
649
655
  if (customWidth) {
650
- if (instance.state.colWidth[hdwidget.uniqueColumnId] != customWidth)
651
- instance.state.colWidth[hdwidget.uniqueColumnId] = customWidth;
656
+ if (instance.state.colWidth[uniqueColumnId] != customWidth)
657
+ instance.state.colWidth[uniqueColumnId] = customWidth;
652
658
  let s = `${customWidth}px`;
653
659
  style = {
654
660
  ...style,
@@ -686,10 +692,15 @@ export class Grid extends Container {
686
692
 
687
693
  if (colIndex > 0) {
688
694
  let hdinstPrev = line.children[colIndex - 1];
689
- let headerPrev = hdinstPrev.components[`header${l + 1}`];
695
+ let prevLine = 3;
696
+ let headerPrev;
697
+ while (!headerPrev && prevLine >= 0) {
698
+ headerPrev = hdinstPrev.components[`header${prevLine + 1}`];
699
+ prevLine--;
700
+ }
690
701
  if (
691
- (hdinstPrev.widget.resizable || (headerPrev && headerPrev.data.resizable)) &&
692
- headerPrev.data.colSpan < 2
702
+ (hdinstPrev.widget.resizable || headerPrev?.data?.resizable) &&
703
+ headerPrev?.data?.colSpan < 2
693
704
  ) {
694
705
  prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex - 1, true);
695
706
  }
@@ -714,7 +725,7 @@ export class Grid extends Container {
714
725
  onMouseLeave={(e) => this.onHeaderMouseLeave(e, hdinst, l)}
715
726
  onClick={(e) => this.onHeaderClick(e, hdwidget, instance, l)}
716
727
  onContextMenu={onContextMenu}
717
- data-unique-col-id={hdwidget.uniqueColumnId}
728
+ data-unique-col-id={colSpan > 1 ? null: hdwidget.uniqueColumnId}
718
729
  >
719
730
  {getContent(content)}
720
731
  {sortIcon}