-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Table has same height when last row is selected
Before this change, when selecting the last row on a table in VR there has been a 1px jump. Caused by the last row which had the same default border-bottom-height of 2px as all remaining rows. So when selecting the last row, the padding-bottom got reduced (as for all remaining rows) when selecting to make the available space for increasing the border-bottom-width from 1px to 2px. This caused the jump. With this change, when selecting the last row it does not adjust the padding-bottom as it’d be needed for all remaining rows. This keeps the table in the same height in VR.
- Loading branch information
1 parent
40acd3f
commit 8c2a8ce
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { BasePageObject } from '@cloudscape-design/browser-test-tools/page-objects'; | ||
import useBrowser from '@cloudscape-design/browser-test-tools/use-browser'; | ||
import createWrapper from '../../../lib/components/test-utils/selectors'; | ||
|
||
const tableWrapper = createWrapper().findTable(); | ||
|
||
class TablePage extends BasePageObject { | ||
async selectFirstRow() { | ||
await this.click(tableWrapper.findRowSelectionArea(1).toSelector()); | ||
} | ||
|
||
async selectLastRow() { | ||
const rowCount = await this.getElementsCount(tableWrapper.findRows().toSelector()); | ||
await this.click(tableWrapper.findRowSelectionArea(rowCount).toSelector()); | ||
} | ||
|
||
async selectAll() { | ||
await this.click(tableWrapper.findSelectAllTrigger().toSelector()); | ||
} | ||
|
||
async getTableHeight() { | ||
const { height } = await this.getBoundingBox(tableWrapper.toSelector()); | ||
return height; | ||
} | ||
} | ||
|
||
describe('Selection has no effect on table height', () => { | ||
const setupTest = (testFn: (page: TablePage) => Promise<void>) => { | ||
return useBrowser(async browser => { | ||
const page = new TablePage(browser); | ||
await browser.url('#/light/table/shift-selection'); | ||
await page.waitForVisible(tableWrapper.findBodyCell(2, 1).toSelector()); | ||
await testFn(page); | ||
}); | ||
}; | ||
|
||
test( | ||
'select last row does not change table height', | ||
setupTest(async page => { | ||
const heightNoSelection = await page.getTableHeight(); | ||
await page.selectLastRow(); | ||
const heightWithLastRowSelected = await page.getTableHeight(); | ||
await expect(heightWithLastRowSelected).toBe(heightNoSelection); | ||
}) | ||
); | ||
|
||
test( | ||
'select first row does not change table height', | ||
setupTest(async page => { | ||
const heightNoSelection = await page.getTableHeight(); | ||
await page.selectFirstRow(); | ||
const heightWithLastRowSelected = await page.getTableHeight(); | ||
await expect(heightWithLastRowSelected).toBe(heightNoSelection); | ||
}) | ||
); | ||
|
||
test( | ||
'select first and last row does not change table height', | ||
setupTest(async page => { | ||
const heightNoSelection = await page.getTableHeight(); | ||
await page.selectFirstRow(); | ||
await page.selectLastRow(); | ||
const heightWithLastRowSelected = await page.getTableHeight(); | ||
await expect(heightWithLastRowSelected).toBe(heightNoSelection); | ||
}) | ||
); | ||
|
||
test( | ||
'select all rows not change table height', | ||
setupTest(async page => { | ||
const heightNoSelection = await page.getTableHeight(); | ||
await page.selectAll(); | ||
const heightWithLastRowSelected = await page.getTableHeight(); | ||
await expect(heightWithLastRowSelected).toBe(heightNoSelection); | ||
}) | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters