@atlaskit/editor-plugin-table 5.4.0 → 5.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#43829](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43829) [`40e78202328`](https://bitbucket.org/atlassian/atlassian-frontend/commits/40e78202328) - The table autoscroller has been updated to fix a bug which occured when rows were dragged to the bottom of the table, it would jump up.
8
+
3
9
  ## 5.4.0
4
10
 
5
11
  ### Minor Changes
@@ -350,9 +350,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
350
350
  canScroll: function canScroll(_ref5) {
351
351
  var source = _ref5.source;
352
352
  var _ref6 = source.data,
353
- localId = _ref6.localId;
353
+ localId = _ref6.localId,
354
+ type = _ref6.type;
354
355
  var node = getNode();
355
- return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId);
356
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
356
357
  },
357
358
  getOverflow: function getOverflow() {
358
359
  return {
@@ -351,10 +351,11 @@ class TableComponent extends React.Component {
351
351
  source
352
352
  }) => {
353
353
  const {
354
- localId
354
+ localId,
355
+ type
355
356
  } = source.data;
356
357
  const node = getNode();
357
- return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId);
358
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
358
359
  },
359
360
  getOverflow: () => ({
360
361
  fromTopEdge: {
@@ -343,9 +343,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
343
343
  canScroll: function canScroll(_ref5) {
344
344
  var source = _ref5.source;
345
345
  var _ref6 = source.data,
346
- localId = _ref6.localId;
346
+ localId = _ref6.localId,
347
+ type = _ref6.type;
347
348
  var node = getNode();
348
- return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId);
349
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
349
350
  },
350
351
  getOverflow: function getOverflow() {
351
352
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.4.0",
3
+ "version": "5.4.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -215,9 +215,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
215
215
  unsafeOverflowAutoScrollForElements({
216
216
  element: this.wrapper,
217
217
  canScroll: ({ source }) => {
218
- const { localId } = source.data as Partial<DraggableSourceData>;
218
+ const { localId, type } =
219
+ source.data as Partial<DraggableSourceData>;
219
220
  const node = getNode();
220
- return localId === node?.attrs.localId;
221
+ return localId === node?.attrs.localId && type === 'table-column';
221
222
  },
222
223
  getOverflow: () => ({
223
224
  fromTopEdge: {
@@ -1,491 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
2
- import {
3
- fullpage,
4
- resizeColumn,
5
- } from '@atlaskit/editor-test-helpers/integration/helpers';
6
- // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
7
- import {
8
- insertColumn,
9
- insertTable,
10
- } from '@atlaskit/editor-test-helpers/page-objects/table';
11
- // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
12
- import {
13
- goToEditorTestingWDExample,
14
- mountEditor,
15
- } from '@atlaskit/editor-test-helpers/testing-example-page';
16
- import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
17
- import type WebdriverPage from '@atlaskit/webdriver-runner/wd-wrapper';
18
-
19
- import basicTableAdf from './__fixtures__/basic-table';
20
- import { emptyLayout } from './__fixtures__/empty-layout';
21
- import nestedInExpand from './__fixtures__/nested-in-expand';
22
- import { nestedInExtension } from './__fixtures__/nested-in-extension';
23
- import { table as tableInsideLayout } from './__fixtures__/table-inside-layout';
24
-
25
- // TODO - Add wider screen size here once editor-common fix is made ED-16647
26
- const screenWidths = [1920];
27
-
28
- const breakout = async (
29
- page: WebdriverPage,
30
- breakoutButton: WebdriverIO.Element,
31
- ) => {
32
- let tableContainer = await page.$('.pm-table-container');
33
-
34
- const currentWidth = await tableContainer.getCSSProperty('width');
35
- breakoutButton.click();
36
-
37
- await page.waitUntil(async () => {
38
- tableContainer = await page.$('.pm-table-container');
39
- const updatedWidth = await tableContainer.getCSSProperty('width');
40
- return updatedWidth.value !== currentWidth.value;
41
- });
42
- };
43
-
44
- const assertTableDoesNotScroll = async (page: WebdriverPage) => {
45
- const table = await page.$('.pm-table-wrapper');
46
-
47
- const tableScrollWidth = await table.getProperty('scrollWidth');
48
- const tableOffsetWidth = await table.getProperty('offsetWidth');
49
-
50
- expect(tableScrollWidth).toEqual(tableOffsetWidth);
51
- };
52
-
53
- const assertTableDoesScroll = async (page: WebdriverPage) => {
54
- const table = await page.$('.pm-table-wrapper');
55
-
56
- const tableScrollWidth = await table.getProperty('scrollWidth');
57
- const tableOffsetWidth = (await table.getProperty('offsetWidth')) as number;
58
-
59
- expect(tableScrollWidth).toBeGreaterThan(tableOffsetWidth);
60
- };
61
-
62
- BrowserTestCase(
63
- 'Table: Does not scroll when column is resized and a new column is inserted',
64
- { skip: [] },
65
- async (client: any, testName: string) => {
66
- for (const screenWidth of screenWidths) {
67
- const page = await goToEditorTestingWDExample(
68
- client,
69
- 'editor-plugin-table',
70
- { width: screenWidth, height: 1440 },
71
- );
72
-
73
- await mountEditor(page, {
74
- appearance: fullpage.appearance,
75
- defaultValue: basicTableAdf,
76
- allowTables: {
77
- advanced: true,
78
- allowDistributeColumns: true,
79
- },
80
- allowLayouts: true,
81
- });
82
-
83
- await resizeColumn(page, { cellHandlePos: 2, resizeWidth: -100 });
84
- await insertColumn(page, 0, 'right');
85
- await assertTableDoesNotScroll(page);
86
- }
87
- },
88
- );
89
-
90
- BrowserTestCase(
91
- 'Table: Does not scroll when column is resized and breakout button is clicked 3x',
92
- { skip: ['safari'] },
93
- async (client: any, testName: string) => {
94
- for (const screenWidth of screenWidths) {
95
- const page = await goToEditorTestingWDExample(
96
- client,
97
- 'editor-plugin-table',
98
- { width: screenWidth, height: 1440 },
99
- );
100
-
101
- await mountEditor(page, {
102
- appearance: fullpage.appearance,
103
- defaultValue: basicTableAdf,
104
- allowTables: {
105
- advanced: true,
106
- allowDistributeColumns: true,
107
- },
108
- allowLayouts: true,
109
- allowBreakout: true,
110
- });
111
-
112
- await resizeColumn(page, { cellHandlePos: 2, resizeWidth: -100 });
113
- await insertColumn(page, 0, 'right');
114
-
115
- const breakoutButton = await page.$('[aria-label="Go wide"]');
116
-
117
- await breakout(page, breakoutButton);
118
- await assertTableDoesNotScroll(page);
119
-
120
- await breakout(page, breakoutButton);
121
- await assertTableDoesNotScroll(page);
122
-
123
- await breakout(page, breakoutButton);
124
- await assertTableDoesNotScroll(page);
125
- }
126
- },
127
- );
128
-
129
- BrowserTestCase(
130
- 'Table: Does not scroll when nested in expand, column is resized and breakout button is clicked',
131
- { skip: [] },
132
- async (client: any, testName: string) => {
133
- for (const screenWidth of screenWidths) {
134
- const page = await goToEditorTestingWDExample(
135
- client,
136
- 'editor-plugin-table',
137
- { width: screenWidth, height: 1440 },
138
- );
139
-
140
- await mountEditor(page, {
141
- appearance: fullpage.appearance,
142
- defaultValue: nestedInExpand,
143
- allowTables: {
144
- advanced: true,
145
- allowDistributeColumns: true,
146
- },
147
- allowExpand: true,
148
- allowLayouts: true,
149
- allowBreakout: true,
150
- });
151
-
152
- const breakoutButton = await page.$('[aria-label="Go wide"]');
153
-
154
- await resizeColumn(page, { cellHandlePos: 3, resizeWidth: -100 });
155
- await breakout(page, breakoutButton);
156
- await assertTableDoesNotScroll(page);
157
- }
158
- },
159
- );
160
-
161
- BrowserTestCase(
162
- 'Table: Last column can be resized to remove scroll',
163
- { skip: [] },
164
- async (client: any, testName: string) => {
165
- for (const screenWidth of screenWidths) {
166
- const page = await goToEditorTestingWDExample(
167
- client,
168
- 'editor-plugin-table',
169
- { width: screenWidth, height: 1440 },
170
- );
171
-
172
- await mountEditor(page, {
173
- appearance: fullpage.appearance,
174
- defaultValue: basicTableAdf,
175
- allowTables: {
176
- advanced: true,
177
- allowDistributeColumns: true,
178
- },
179
- allowExpand: true,
180
- allowLayouts: true,
181
- allowBreakout: true,
182
- });
183
-
184
- await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
185
- await assertTableDoesScroll(page);
186
- await resizeColumn(page, { cellHandlePos: 10, resizeWidth: -1000 });
187
- await assertTableDoesNotScroll(page);
188
- }
189
- },
190
- );
191
-
192
- BrowserTestCase(
193
- 'Table: When nested in expand, last column can be resized to remove scroll',
194
- { skip: [] },
195
- async (client: any, testName: string) => {
196
- for (const screenWidth of screenWidths) {
197
- const page = await goToEditorTestingWDExample(
198
- client,
199
- 'editor-plugin-table',
200
- { width: screenWidth, height: 1440 },
201
- );
202
-
203
- await mountEditor(page, {
204
- appearance: fullpage.appearance,
205
- defaultValue: nestedInExpand,
206
- allowTables: {
207
- advanced: true,
208
- allowDistributeColumns: true,
209
- },
210
- allowExpand: true,
211
- allowLayouts: true,
212
- allowBreakout: true,
213
- });
214
-
215
- await resizeColumn(page, { cellHandlePos: 3, resizeWidth: 1000 });
216
- await assertTableDoesScroll(page);
217
- await resizeColumn(page, { cellHandlePos: 11, resizeWidth: -1000 });
218
- await assertTableDoesNotScroll(page);
219
- }
220
- },
221
- );
222
-
223
- BrowserTestCase(
224
- 'Table: When nested in layout, last column can be resized to remove scroll',
225
- { skip: [] },
226
- async (client: any, testName: string) => {
227
- for (const screenWidth of screenWidths) {
228
- const page = await goToEditorTestingWDExample(
229
- client,
230
- 'editor-plugin-table',
231
- { width: screenWidth, height: 1440 },
232
- );
233
-
234
- await mountEditor(page, {
235
- appearance: fullpage.appearance,
236
- defaultValue: tableInsideLayout,
237
- allowTables: {
238
- advanced: true,
239
- allowDistributeColumns: true,
240
- },
241
- allowExpand: true,
242
- allowLayouts: true,
243
- allowBreakout: true,
244
- });
245
-
246
- await resizeColumn(page, { cellHandlePos: 8, resizeWidth: 1000 });
247
- await assertTableDoesScroll(page);
248
- await resizeColumn(page, { cellHandlePos: 16, resizeWidth: -1000 });
249
- await assertTableDoesNotScroll(page);
250
- }
251
- },
252
- );
253
-
254
- BrowserTestCase(
255
- 'Table: When nested in bodied macro, last column can be resized to remove scroll',
256
- { skip: [] },
257
- async (client: any, testName: string) => {
258
- for (const screenWidth of screenWidths) {
259
- const page = await goToEditorTestingWDExample(
260
- client,
261
- 'editor-plugin-table',
262
- { width: screenWidth, height: 1440 },
263
- );
264
-
265
- await mountEditor(page, {
266
- appearance: fullpage.appearance,
267
- defaultValue: nestedInExtension,
268
- allowTables: {
269
- advanced: true,
270
- allowDistributeColumns: true,
271
- },
272
- allowExpand: true,
273
- allowLayouts: true,
274
- allowBreakout: true,
275
- allowExtension: true,
276
- });
277
-
278
- await resizeColumn(page, { cellHandlePos: 3, resizeWidth: 1000 });
279
- await assertTableDoesScroll(page);
280
- await resizeColumn(page, { cellHandlePos: 11, resizeWidth: -1000 });
281
- await assertTableDoesNotScroll(page);
282
- }
283
- },
284
- );
285
-
286
- BrowserTestCase(
287
- 'Table: Scrolls when there are more columns added than can fit the current width',
288
- { skip: [] },
289
- async (client: any, testName: string) => {
290
- for (const screenWidth of screenWidths) {
291
- const page = await goToEditorTestingWDExample(
292
- client,
293
- 'editor-plugin-table',
294
- { width: screenWidth, height: 1440 },
295
- );
296
-
297
- await mountEditor(page, {
298
- appearance: fullpage.appearance,
299
- defaultValue: basicTableAdf,
300
- allowTables: {
301
- advanced: true,
302
- allowDistributeColumns: true,
303
- },
304
- allowExpand: true,
305
- allowLayouts: true,
306
- allowBreakout: true,
307
- });
308
-
309
- const numberOfColumns = 14;
310
- for (const _column of [...Array(numberOfColumns).keys()]) {
311
- await insertColumn(page, 0, 'right');
312
- }
313
-
314
- await assertTableDoesScroll(page);
315
- }
316
- },
317
- );
318
-
319
- BrowserTestCase(
320
- 'Table: Does not scroll when nested in Bodied Macro, column is resized and breakout button is clicked',
321
- { skip: [] },
322
- async (client: any, testName: string) => {
323
- for (const screenWidth of screenWidths) {
324
- const page = await goToEditorTestingWDExample(
325
- client,
326
- 'editor-plugin-table',
327
- { width: screenWidth, height: 1440 },
328
- );
329
-
330
- await mountEditor(page, {
331
- appearance: fullpage.appearance,
332
- defaultValue: JSON.stringify(nestedInExtension),
333
- allowTables: {
334
- advanced: true,
335
- },
336
- allowExtension: true,
337
- });
338
-
339
- await resizeColumn(page, { cellHandlePos: 3, resizeWidth: -100 });
340
- await insertColumn(page, 0, 'right');
341
- await assertTableDoesNotScroll(page);
342
- }
343
- },
344
- );
345
-
346
- BrowserTestCase(
347
- 'Table: Does not scroll when nested in layout, column is resized and breakout button is clicked',
348
- { skip: [] },
349
- async (client: any, testName: string) => {
350
- for (const screenWidth of screenWidths) {
351
- const page = await goToEditorTestingWDExample(
352
- client,
353
- 'editor-plugin-table',
354
- { width: screenWidth, height: 1440 },
355
- );
356
-
357
- await mountEditor(page, {
358
- appearance: fullpage.appearance,
359
- defaultValue: JSON.stringify(tableInsideLayout),
360
- allowTables: {
361
- advanced: true,
362
- },
363
- allowLayouts: {
364
- allowBreakout: true,
365
- },
366
- allowBreakout: true,
367
- });
368
-
369
- const breakoutButton = await page.$('[aria-label="Go wide"]');
370
-
371
- await resizeColumn(page, { cellHandlePos: 8, resizeWidth: -100 });
372
- await breakout(page, breakoutButton);
373
- await assertTableDoesNotScroll(page);
374
- }
375
- },
376
- );
377
-
378
- BrowserTestCase(
379
- 'Table: Does not scroll when nested in single column layout, table column is resized and breakout button is clicked',
380
- { skip: [] },
381
- async (client: any, testName: string) => {
382
- for (const screenWidth of screenWidths) {
383
- const page = await goToEditorTestingWDExample(
384
- client,
385
- 'editor-plugin-table',
386
- { width: screenWidth, height: 1440 },
387
- );
388
-
389
- await mountEditor(page, {
390
- appearance: fullpage.appearance,
391
- defaultValue: JSON.stringify(tableInsideLayout),
392
- allowTables: {
393
- advanced: true,
394
- allowDistributeColumns: true,
395
- },
396
- allowLayouts: {
397
- allowBreakout: true,
398
- UNSAFE_allowSingleColumnLayout: true,
399
- },
400
- allowBreakout: true,
401
- });
402
-
403
- await resizeColumn(page, { cellHandlePos: 8, resizeWidth: -100 });
404
-
405
- const singleColumnButton = await page.$('[aria-label="Single column"]');
406
- singleColumnButton.click();
407
-
408
- const breakoutButton = await page.$('[aria-label="Go wide"]');
409
-
410
- await breakout(page, breakoutButton);
411
- await assertTableDoesNotScroll(page);
412
- }
413
- },
414
- );
415
-
416
- BrowserTestCase(
417
- 'Table: Does not scroll when nested in three columns layout, table column is resized and breakout button is clicked',
418
- { skip: [] },
419
- async (client: any, testName: string) => {
420
- for (const screenWidth of screenWidths) {
421
- const page = await goToEditorTestingWDExample(
422
- client,
423
- 'editor-plugin-table',
424
- { width: screenWidth, height: 1440 },
425
- );
426
-
427
- await mountEditor(page, {
428
- appearance: fullpage.appearance,
429
- defaultValue: JSON.stringify(tableInsideLayout),
430
- allowTables: {
431
- advanced: true,
432
- allowDistributeColumns: true,
433
- },
434
- allowLayouts: {
435
- allowBreakout: true,
436
- UNSAFE_allowSingleColumnLayout: true,
437
- },
438
- allowBreakout: true,
439
- });
440
-
441
- await resizeColumn(page, { cellHandlePos: 8, resizeWidth: -100 });
442
-
443
- const threeColumnButton = await page.$('[aria-label="Three columns"]');
444
- threeColumnButton.click();
445
-
446
- const breakoutButton = await page.$('[aria-label="Go wide"]');
447
-
448
- await breakout(page, breakoutButton);
449
- await assertTableDoesNotScroll(page);
450
- }
451
- },
452
- );
453
-
454
- // FIXME: This test was automatically skipped due to failure on 28/07/2023: https://product-fabric.atlassian.net/browse/ED-19288
455
- BrowserTestCase(
456
- 'Table: Does not scroll when nested in full-width layout, columns is resized and new column is inserted',
457
- {
458
- skip: ['*'],
459
- },
460
- async (client: any, testName: string) => {
461
- for (const screenWidth of screenWidths) {
462
- const page = await goToEditorTestingWDExample(
463
- client,
464
- 'editor-plugin-table',
465
- { width: screenWidth, height: 1440 },
466
- );
467
-
468
- await mountEditor(page, {
469
- appearance: fullpage.appearance,
470
- defaultValue: emptyLayout,
471
- allowTables: {
472
- advanced: true,
473
- },
474
- allowLayouts: {
475
- allowBreakout: true,
476
- },
477
- allowBreakout: true,
478
- });
479
-
480
- const goWideButton = await page.$('[aria-label="Go wide"]');
481
- goWideButton.click();
482
- goWideButton.click();
483
-
484
- insertTable(page);
485
- await assertTableDoesNotScroll(page);
486
- await resizeColumn(page, { cellHandlePos: 4, resizeWidth: -100 });
487
- await insertColumn(page, 0, 'right');
488
- await assertTableDoesNotScroll(page);
489
- }
490
- },
491
- );