Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: [M3-8817] - Replace PageSize autocomplete with simple select #11203

Merged
merged 8 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Replace Pagination page size autocomplete with simple select ([#11203](https://github.com/linode/manager/pull/11203))
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ describe('Account invoices', () => {
cy.findByLabelText('Invoice Details').within(() => {
// Confirm that page size selection is set to "Show 25".
ui.pagination.findPageSizeSelect().click();
ui.autocompletePopper.findByTitle('Show 25').should('be.visible').click();
cy.get('[data-qa-pagination-page-size-option="25"]')
.should('exist')
.click();

// Confirm that pagination controls list exactly 4 pages.
ui.pagination
Expand Down Expand Up @@ -337,9 +339,8 @@ describe('Account invoices', () => {

// Change pagination size selection from "Show 25" to "Show 100".
ui.pagination.findPageSizeSelect().click();
ui.autocompletePopper
.findByTitle('Show 100')
.should('be.visible')
cy.get('[data-qa-pagination-page-size-option="100"]')
.should('exist')
.click();

// Confirm that all invoice items are listed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ describe('Billing Activity Feed', () => {
.within(() => {
// Confirm that pagination page size selection is set to "Show 25".
ui.pagination.findPageSizeSelect().click();

ui.select.findItemByText('Show 25').should('be.visible').click();
cy.get('[data-qa-pagination-page-size-option="25"]')
.should('exist')
.click();

// Confirm that pagination controls list exactly 4 pages.
ui.pagination
Expand Down Expand Up @@ -309,8 +310,9 @@ describe('Billing Activity Feed', () => {

// Change page size selection from "Show 25" to "Show 100".
ui.pagination.findPageSizeSelect().click();

ui.select.findItemByText('Show 100').should('be.visible').click();
cy.get('[data-qa-pagination-page-size-option="100"]')
.should('exist')
.click();

// Confirm that all 100 invoices are shown.
cy.get('tr').should('have.length', 101);
Expand Down
18 changes: 9 additions & 9 deletions packages/manager/cypress/support/ui/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ export const pagination = {
},

/**
* Finds the pagination page size selection.
* Finds the pagination page selection controls.
*
* @returns Cypress chainable.
*/
findPageSizeSelect: () => {
return pagination
.find()
.find('[data-qa-pagination-page-size]')
.find('[data-qa-autocomplete]');
findControls: () => {
return pagination.find().find('[data-qa-pagination-controls]');
},

/**
* Finds the pagination page selection controls.
* Finds the pagination page size selection.
*
* @returns Cypress chainable.
*/
findControls: () => {
return pagination.find().find('[data-qa-pagination-controls]');
findPageSizeSelect: () => {
return pagination
.find()
.find('[data-qa-pagination-page-size]')
.find('[role="combobox"]');
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Box } from '@linode/ui';
import { styled, useTheme } from '@mui/material/styles';
import * as React from 'react';

import { Autocomplete } from 'src/components/Autocomplete/Autocomplete';
import { MenuItem } from 'src/components/MenuItem';

import { PaginationControls } from '../PaginationControls/PaginationControls';
import { TextField } from '../TextField';

export const MIN_PAGE_SIZE = 25;

Expand Down Expand Up @@ -80,36 +81,58 @@ export const PaginationFooter = (props: Props) => {
/>
)}
{!fixedSize ? (
<PageSizeSelectContainer data-qa-pagination-page-size>
<Autocomplete
disableClearable
<Box data-qa-pagination-page-size padding={0.5}>
<StyledTextField
SelectProps={{
MenuProps: {
disablePortal: true,
},
}}
defaultValue={defaultPagination}
hideLabel
label="Number of items to show"
onChange={(_, selected) => handleSizeChange(selected.value)}
options={finalOptions}
textFieldProps={{ hideLabel: true, noMarginTop: true }}
value={defaultPagination}
/>
</PageSizeSelectContainer>
onChange={(e) => handleSizeChange(Number(e.target.value))}
select
value={pageSize}
>
{finalOptions.map((option) => (
<MenuItem
data-qa-pagination-page-size-option={option.value}
key={option.value}
value={option.value}
>
{option.label}
</MenuItem>
))}
</StyledTextField>
</Box>
) : null}
</Box>
);
};

const PageSizeSelectContainer = styled(Box, {
label: 'PageSizeSelectContainer',
const StyledTextField = styled(TextField, {
label: 'StyledTextField',
})(({ theme }) => ({
'& .MuiInput-input': {
paddingTop: 4,
},
'& .MuiInput-root': {
'&.Mui-focused': {
boxShadow: 'none',
},
backgroundColor: theme.bg.bgPaper,
border: '1px solid transparent',
},
'& .MuiList-root': {
border: `1px solid ${theme.palette.primary.main}`,
},
'& .MuiSelect-select': {
border: 'none',
},
'& .react-select__value-container': {
paddingLeft: 12,
'& .MuiSvgIcon-root': {
margin: 0,
padding: 0,
position: 'relative',
top: 0,
},
'&.Mui-focused': {
border: `1px dotted ${theme.color.grey1}`,
boxShadow: 'none',
},
}));

Expand Down