@worktile/theia 15.0.6 → 15.0.8

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.
@@ -3155,6 +3155,7 @@ class TheContextService {
3155
3155
  };
3156
3156
  this.containerScrolled$ = new Subject();
3157
3157
  this.uploadingStatus$ = new Subject();
3158
+ this.containerResized$ = new Subject();
3158
3159
  this.ngZone.runOutsideAngular(() => {
3159
3160
  this.onMouseUp$ = fromEvent(window, `mouseup`).pipe(takeUntil(this.destroy$));
3160
3161
  this.onMouseMove$ = fromEvent(window, `mousemove`).pipe(takeUntil(this.destroy$));
@@ -3164,6 +3165,7 @@ class TheContextService {
3164
3165
  initialize(options) {
3165
3166
  this.options = options;
3166
3167
  this.rebindContainerScroll();
3168
+ this.bindContainerResize();
3167
3169
  }
3168
3170
  rebindContainerScroll() {
3169
3171
  this.scrollSubscription?.unsubscribe();
@@ -3179,6 +3181,10 @@ class TheContextService {
3179
3181
  }
3180
3182
  }
3181
3183
  }
3184
+ bindContainerResize() {
3185
+ this.resizeObserver = new ResizeObserver(entires => this.containerResized$.next(entires));
3186
+ return this.resizeObserver.observe(this.options.nativeElement);
3187
+ }
3182
3188
  getOptions() {
3183
3189
  if (!this.options.width) {
3184
3190
  const firstElementChild = this.getFirstElementChild();
@@ -3208,6 +3214,8 @@ class TheContextService {
3208
3214
  ngOnDestroy() {
3209
3215
  this.uploadingStatus$.complete();
3210
3216
  this.containerScrolled$?.complete();
3217
+ this.containerResized$?.complete();
3218
+ this.resizeObserver.disconnect();
3211
3219
  this.scrollSubscription?.unsubscribe();
3212
3220
  this.destroy$.next();
3213
3221
  this.destroy$.complete();
@@ -12823,6 +12831,7 @@ class TheTableComponent extends TheBaseElementComponent {
12823
12831
  }
12824
12832
  this.setHeaderCellStyle();
12825
12833
  this.subscribeScrollContainerScroll();
12834
+ this.contextService.containerResized$.pipe(takeUntil(this.destroy$)).subscribe(() => this.setHeaderRowStyle());
12826
12835
  });
12827
12836
  }
12828
12837
  subscribeScrollContainerScroll() {
@@ -12905,25 +12914,21 @@ class TheTableComponent extends TheBaseElementComponent {
12905
12914
  }
12906
12915
  setGridColumnsStyle() {
12907
12916
  const colControl = this.columnControlsWrapper.nativeElement;
12908
- const headerRow = this.nativeElement.querySelector('tbody tr');
12909
- const stickyRows = this.isInTable ? [colControl, headerRow] : [headerRow];
12917
+ const rows = [...this.nativeElement.querySelectorAll('tbody tr')];
12918
+ // 只有一行的表格不支持固定
12919
+ if (rows.length <= 1) {
12920
+ return;
12921
+ }
12910
12922
  if (this.freezeRowPipe.transform(this.element, this.headerRow, this.tablePluginOptions)) {
12911
12923
  let gridColumns = '';
12912
12924
  const tablePadding = 44;
12913
- let tableWidth = this.elementRef.nativeElement.offsetWidth;
12925
+ let tableWidth = this.tableWrapper.nativeElement.getBoundingClientRect().width;
12914
12926
  tableWidth = this.element.options?.numberedColumn ? tableWidth - tablePadding : tableWidth;
12915
- const colgroup = this.nativeElement.querySelector('colgroup');
12916
- let cellElements;
12917
- if (colgroup && !this.tableStore.isFullscreen) {
12918
- cellElements = [...this.nativeElement.querySelector('colgroup').children];
12919
- }
12920
- else {
12921
- /* 默认插入的表格元素是没有 columns 字段的(后来做的),所以也就不会渲染 colgroup */
12922
- cellElements = [...headerRow.querySelectorAll('td')];
12923
- }
12927
+ const cellElements = [...rows[1].querySelectorAll('td')];
12924
12928
  cellElements.forEach(item => {
12925
- gridColumns += getElementWidth(item) + 'px ';
12929
+ gridColumns += item.getBoundingClientRect().width + 'px ';
12926
12930
  });
12931
+ const stickyRows = this.isInTable ? [colControl, rows[0]] : [rows[0]];
12927
12932
  stickyRows.map(item => {
12928
12933
  this.renderer.setStyle(item, 'grid-template-columns', gridColumns);
12929
12934
  this.renderer.setStyle(item, 'width', tableWidth + 'px');
@@ -13350,8 +13355,11 @@ class TheTableComponent extends TheBaseElementComponent {
13350
13355
  if (this.isStickyTop) {
13351
13356
  const stickyRows = this.elementRef.nativeElement.querySelectorAll('.the-sticky-row');
13352
13357
  for (const stiRow of stickyRows) {
13353
- // 同步滚动状态到 .the-sticky-row
13354
- stiRow.scrollLeft = this.tableWrapper.nativeElement.scrollLeft;
13358
+ // 修复获取 scrollLeft 属性引起的浏览器重绘,导致跳动问题 #WIK-11038
13359
+ requestAnimationFrame(() => {
13360
+ // 同步滚动状态到 .the-sticky-row
13361
+ stiRow.scrollLeft = this.tableWrapper.nativeElement.scrollLeft;
13362
+ });
13355
13363
  }
13356
13364
  }
13357
13365
  }