@atlaskit/editor-plugin-table 0.0.8 → 0.0.9
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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/esm/version.json +1 -1
- package/package.json +1 -1
- package/src/plugins/table/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -47
- package/src/plugins/table/nodeviews/TableComponent.tsx +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 0.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`30d47a9f80d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30d47a9f80d) - This change adds data-testid to the top and bottom sticky sentinels in TableComponent and updates tests to access the sentinels by the testId.
|
|
8
|
+
|
|
3
9
|
## 0.0.8
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -558,7 +558,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
558
558
|
"data-number-column": node.attrs.isNumberColumnEnabled,
|
|
559
559
|
"data-layout": node.attrs.layout
|
|
560
560
|
}, stickyHeadersOptimization && /*#__PURE__*/_react.default.createElement("div", {
|
|
561
|
-
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP
|
|
561
|
+
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
562
|
+
"data-testid": "sticky-sentinel-top"
|
|
562
563
|
}), allowControls && (!isLoading || initialRenderOptimization) && rowControls, /*#__PURE__*/_react.default.createElement("div", {
|
|
563
564
|
style: shadowStyle(showBeforeShadow),
|
|
564
565
|
className: _types.TableCssClassName.TABLE_LEFT_SHADOW
|
|
@@ -598,7 +599,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
598
599
|
top: "".concat(this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2, "px")
|
|
599
600
|
}
|
|
600
601
|
})), stickyHeadersOptimization && /*#__PURE__*/_react.default.createElement("div", {
|
|
601
|
-
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM
|
|
602
|
+
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM,
|
|
603
|
+
"data-testid": "sticky-sentinel-bottom"
|
|
602
604
|
}));
|
|
603
605
|
}
|
|
604
606
|
}]);
|
package/dist/cjs/version.json
CHANGED
|
@@ -528,7 +528,8 @@ class TableComponent extends React.Component {
|
|
|
528
528
|
"data-number-column": node.attrs.isNumberColumnEnabled,
|
|
529
529
|
"data-layout": node.attrs.layout
|
|
530
530
|
}, stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
|
|
531
|
-
className: ClassName.TABLE_STICKY_SENTINEL_TOP
|
|
531
|
+
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
532
|
+
"data-testid": "sticky-sentinel-top"
|
|
532
533
|
}), allowControls && (!isLoading || initialRenderOptimization) && rowControls, /*#__PURE__*/React.createElement("div", {
|
|
533
534
|
style: shadowStyle(showBeforeShadow),
|
|
534
535
|
className: ClassName.TABLE_LEFT_SHADOW
|
|
@@ -567,7 +568,8 @@ class TableComponent extends React.Component {
|
|
|
567
568
|
top: `${this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2}px`
|
|
568
569
|
}
|
|
569
570
|
})), stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
|
|
570
|
-
className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM
|
|
571
|
+
className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM,
|
|
572
|
+
"data-testid": "sticky-sentinel-bottom"
|
|
571
573
|
}));
|
|
572
574
|
}
|
|
573
575
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -543,7 +543,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
543
543
|
"data-number-column": node.attrs.isNumberColumnEnabled,
|
|
544
544
|
"data-layout": node.attrs.layout
|
|
545
545
|
}, stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
|
|
546
|
-
className: ClassName.TABLE_STICKY_SENTINEL_TOP
|
|
546
|
+
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
547
|
+
"data-testid": "sticky-sentinel-top"
|
|
547
548
|
}), allowControls && (!isLoading || initialRenderOptimization) && rowControls, /*#__PURE__*/React.createElement("div", {
|
|
548
549
|
style: shadowStyle(showBeforeShadow),
|
|
549
550
|
className: ClassName.TABLE_LEFT_SHADOW
|
|
@@ -583,7 +584,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
583
584
|
top: "".concat(this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2, "px")
|
|
584
585
|
}
|
|
585
586
|
})), stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
|
|
586
|
-
className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM
|
|
587
|
+
className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM,
|
|
588
|
+
"data-testid": "sticky-sentinel-bottom"
|
|
587
589
|
}));
|
|
588
590
|
}
|
|
589
591
|
}]);
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -33,9 +33,9 @@ jest.mock('@atlaskit/editor-common/ui', () => ({
|
|
|
33
33
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
34
34
|
import { updateStickyState } from '../../../../pm-plugins/sticky-headers/commands';
|
|
35
35
|
import { TableCssClassName } from '../../../../types';
|
|
36
|
-
import { mount } from 'enzyme';
|
|
37
36
|
import TableComponent from '../../../../nodeviews/TableComponent';
|
|
38
37
|
import React from 'react';
|
|
38
|
+
import { render, screen } from '@testing-library/react';
|
|
39
39
|
import {
|
|
40
40
|
stickyRowOffsetTop,
|
|
41
41
|
tableScrollbarOffset,
|
|
@@ -388,13 +388,13 @@ describe('TableRowNodeView', () => {
|
|
|
388
388
|
return scrollContainer;
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
function
|
|
391
|
+
function renderTableComponent({
|
|
392
392
|
disableContentDomMock,
|
|
393
393
|
}: {
|
|
394
394
|
disableContentDomMock?: true;
|
|
395
395
|
} = {}) {
|
|
396
396
|
const getNode = () => editorView.state.doc.firstChild;
|
|
397
|
-
return
|
|
397
|
+
return render(
|
|
398
398
|
<TableComponent
|
|
399
399
|
view={editorView}
|
|
400
400
|
eventDispatcher={eventDispatcher}
|
|
@@ -428,28 +428,21 @@ describe('TableRowNodeView', () => {
|
|
|
428
428
|
});
|
|
429
429
|
|
|
430
430
|
it('sentinel elements are rendered inside table component', () => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
);
|
|
436
|
-
|
|
437
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM}`,
|
|
438
|
-
);
|
|
439
|
-
expect(sentinelWrapperTop).toHaveLength(1);
|
|
440
|
-
expect(sentinelWrapperBottom).toHaveLength(1);
|
|
431
|
+
renderTableComponent();
|
|
432
|
+
const sentinelTop = screen.getByTestId('sticky-sentinel-top');
|
|
433
|
+
const sentinelBottom = screen.getByTestId('sticky-sentinel-bottom');
|
|
434
|
+
|
|
435
|
+
expect(sentinelTop).toBeTruthy();
|
|
436
|
+
expect(sentinelBottom).toBeTruthy();
|
|
441
437
|
});
|
|
442
438
|
|
|
443
439
|
describe('updates sticky header state', () => {
|
|
444
440
|
it('top sentinel does nothing if the rootBounds has height 0', () => {
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_TOP}`,
|
|
448
|
-
);
|
|
449
|
-
const sentinelTop = sentinelWrapperTop.getDOMNode() as HTMLElement;
|
|
441
|
+
renderTableComponent();
|
|
442
|
+
const sentinelTop = screen.getByTestId('sticky-sentinel-top');
|
|
450
443
|
|
|
451
444
|
triggerElementIntersect({
|
|
452
|
-
target: sentinelTop,
|
|
445
|
+
target: sentinelTop as HTMLElement,
|
|
453
446
|
isIntersecting: false,
|
|
454
447
|
rootBounds: { bottom: 0, top: 0, height: 0 },
|
|
455
448
|
boundingClientRect: { bottom: 0, top: 0 },
|
|
@@ -459,13 +452,10 @@ describe('TableRowNodeView', () => {
|
|
|
459
452
|
});
|
|
460
453
|
|
|
461
454
|
it('bottom sentinel does nothing if the rootBounds has height 0', () => {
|
|
462
|
-
|
|
463
|
-
const
|
|
464
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM}`,
|
|
465
|
-
);
|
|
466
|
-
const sentinelBottom = sentinelWrapperBottom.getDOMNode() as HTMLElement;
|
|
455
|
+
renderTableComponent();
|
|
456
|
+
const sentinelBottom = screen.getByTestId('sticky-sentinel-bottom');
|
|
467
457
|
triggerElementIntersect({
|
|
468
|
-
target: sentinelBottom,
|
|
458
|
+
target: sentinelBottom as HTMLElement,
|
|
469
459
|
isIntersecting: false,
|
|
470
460
|
rootBounds: { bottom: 0, top: 0, height: 0 },
|
|
471
461
|
boundingClientRect: { bottom: 0, top: 0 },
|
|
@@ -474,12 +464,9 @@ describe('TableRowNodeView', () => {
|
|
|
474
464
|
expect(updateStickyState).not.toHaveBeenCalled();
|
|
475
465
|
});
|
|
476
466
|
|
|
477
|
-
it('when top sentinel leaves scroll area', () => {
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_TOP}`,
|
|
481
|
-
);
|
|
482
|
-
const sentinelTop = sentinelWrapperTop.getDOMNode() as HTMLElement;
|
|
467
|
+
it('updates sticky header when top of sticky header sentinel leaves scroll area', () => {
|
|
468
|
+
renderTableComponent();
|
|
469
|
+
const sentinelTop = screen.getByTestId('sticky-sentinel-top');
|
|
483
470
|
|
|
484
471
|
triggerElementIntersect({
|
|
485
472
|
target: sentinelTop,
|
|
@@ -512,12 +499,9 @@ describe('TableRowNodeView', () => {
|
|
|
512
499
|
);
|
|
513
500
|
});
|
|
514
501
|
|
|
515
|
-
it('when bottom sentinel enters or leaves scroll area', () => {
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM}`,
|
|
519
|
-
);
|
|
520
|
-
const sentinelBottom = sentinelWrapperBottom.getDOMNode() as HTMLElement;
|
|
502
|
+
it('updates sticky header when bottom of sticky header sentinel enters or leaves scroll area', () => {
|
|
503
|
+
renderTableComponent();
|
|
504
|
+
const sentinelBottom = screen.getByTestId('sticky-sentinel-bottom');
|
|
521
505
|
|
|
522
506
|
triggerElementIntersect({
|
|
523
507
|
target: sentinelBottom,
|
|
@@ -560,13 +544,10 @@ describe('TableRowNodeView', () => {
|
|
|
560
544
|
(_, contentRectSupported: boolean) => {
|
|
561
545
|
const { tableWrapper } = getTableElements(tableRowDom);
|
|
562
546
|
// disabled due to editorView dom being cleared by use of contentDom mocks
|
|
563
|
-
|
|
547
|
+
renderTableComponent({
|
|
564
548
|
disableContentDomMock: true,
|
|
565
549
|
});
|
|
566
|
-
const
|
|
567
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM}`,
|
|
568
|
-
);
|
|
569
|
-
const sentinelBottom = sentinelWrapperBottom.getDOMNode() as HTMLElement;
|
|
550
|
+
const sentinelBottom = screen.getByTestId('sticky-sentinel-bottom');
|
|
570
551
|
tableWrapper?.appendChild(sentinelBottom);
|
|
571
552
|
rafStub.flush();
|
|
572
553
|
|
|
@@ -584,13 +565,10 @@ describe('TableRowNodeView', () => {
|
|
|
584
565
|
it('marks sentinels as unobserved when isHeaderRowEnabled is set to false', () => {
|
|
585
566
|
const { tableWrapper } = getTableElements(tableRowDom);
|
|
586
567
|
// disabled due to editorView dom being cleared by use of contentDom mocks
|
|
587
|
-
|
|
568
|
+
renderTableComponent({
|
|
588
569
|
disableContentDomMock: true,
|
|
589
570
|
});
|
|
590
|
-
const
|
|
591
|
-
`.${TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM}`,
|
|
592
|
-
);
|
|
593
|
-
const sentinelBottom = sentinelWrapperBottom.getDOMNode() as HTMLElement;
|
|
571
|
+
const sentinelBottom = screen.getByTestId('sticky-sentinel-bottom');
|
|
594
572
|
tableWrapper?.appendChild(sentinelBottom);
|
|
595
573
|
rafStub.flush();
|
|
596
574
|
expect(sentinelBottom.dataset.isObserved).toBeDefined();
|
|
@@ -394,7 +394,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
394
394
|
data-layout={node.attrs.layout}
|
|
395
395
|
>
|
|
396
396
|
{stickyHeadersOptimization && (
|
|
397
|
-
<div
|
|
397
|
+
<div
|
|
398
|
+
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
399
|
+
data-testid="sticky-sentinel-top"
|
|
400
|
+
/>
|
|
398
401
|
)}
|
|
399
402
|
{allowControls &&
|
|
400
403
|
(!isLoading || initialRenderOptimization) &&
|
|
@@ -465,7 +468,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
465
468
|
</div>
|
|
466
469
|
)}
|
|
467
470
|
{stickyHeadersOptimization && (
|
|
468
|
-
<div
|
|
471
|
+
<div
|
|
472
|
+
className={ClassName.TABLE_STICKY_SENTINEL_BOTTOM}
|
|
473
|
+
data-testid="sticky-sentinel-bottom"
|
|
474
|
+
/>
|
|
469
475
|
)}
|
|
470
476
|
</div>
|
|
471
477
|
);
|