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

Fixing Violation Issues of Pagination issue(#6124) #6877

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
623be7b
Fixed Footer violations
UmairAbbas78 May 27, 2023
33c40f9
Fixed Footer Violations 🚀
UmairAbbas78 May 28, 2023
70f82d3
Fixed Violation Issues in Footer (#6124) 🚀
UmairAbbas78 May 28, 2023
1415d0a
Fixed minor issues (#6816) ✅
UmairAbbas78 May 31, 2023
5a86b42
Merge branch 'grommet:master' into master
UmairAbbas78 May 31, 2023
79ec477
Changed back to 'brand' in Social Footer ✅✔
UmairAbbas78 Jun 1, 2023
98aa426
Merge branch 'grommet:master' into master
UmairAbbas78 Jun 3, 2023
a7bbd93
fixed ARIA-ROLE issue ✔
UmairAbbas78 Jun 3, 2023
6c91afe
Merge branch 'master' into master
jcfilben Jun 7, 2023
3dd4ba5
Merge branch 'grommet:master' into master
UmairAbbas78 Jun 10, 2023
69dbf50
testing
UmairAbbas78 Jun 10, 2023
6a008c3
Merge branch 'master' of https://github.com/UmairAbbas78/grommet
UmairAbbas78 Jun 10, 2023
53193cf
Fixed the SelectMultiple-test timeout issue (#6820)
UmairAbbas78 Jun 10, 2023
d241b56
Fixed the SelectMultiple-test timeout issue (grommet#6820)
UmairAbbas78 Jun 10, 2023
8eaffdb
Merge branch 'master' into master
UmairAbbas78 Jun 13, 2023
305ac7d
Merge branch 'grommet:master' into master
UmairAbbas78 Jun 24, 2023
9e8accf
Fixed violations of NumberEdgePages,NumberMiddlePages,Size,Simple iss…
UmairAbbas78 Jul 9, 2023
fda310b
Fixed Violations of NumberEdge,NumberMiddle,Simple,Size Issue(#6124) ✅
UmairAbbas78 Jul 9, 2023
140f361
Fixed Violations of NumberEdge,NumberMiddle,Simple,Size Issue(#6124)
UmairAbbas78 Jul 9, 2023
f36cf52
Fixed Violations of NumberEdge,NumberMiddle,Simple,Size Issue(#6124)
UmairAbbas78 Jul 9, 2023
c15fe85
Merge branch 'master' of https://github.com/UmairAbbas78/grommet
UmairAbbas78 Jul 12, 2023
4486cdf
Fixing Violation Issues of Pagination issue(#6124)
UmairAbbas78 Jul 12, 2023
dcfef4c
Fixed Violations of NumberEdge,NumberMiddle,Simple,Size Issue(#6124)
UmairAbbas78 Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"@types/react": "^18.2.12",
"@types/react-dom": "^18.2.5",
"@types/styled-components": "^5.1.26",
"@types/testing-library__react": "^10.2.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^29.5.0",
"babel-loader": "^9.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4833,75 +4833,6 @@ exports[`DataFilter select multiple options search 2`] = `
line-height: 20px;
}

.c8 {
display: inline-block;
box-sizing: border-box;
cursor: pointer;
font: inherit;
-webkit-text-decoration: none;
text-decoration: none;
margin: 0;
background: transparent;
overflow: visible;
text-transform: none;
border: 2px solid #7D4CDB;
border-radius: 18px;
color: #444444;
padding: 4px 22px;
font-size: 18px;
line-height: 24px;
-webkit-transition-property: color,background-color,border-color,box-shadow;
transition-property: color,background-color,border-color,box-shadow;
-webkit-transition-duration: 0.1s;
transition-duration: 0.1s;
-webkit-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
}

.c8:hover {
box-shadow: 0px 0px 0px 2px #7D4CDB;
}

.c8:focus {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}

.c8:focus > circle,
.c8:focus > ellipse,
.c8:focus > line,
.c8:focus > path,
.c8:focus > polygon,
.c8:focus > polyline,
.c8:focus > rect {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}

.c8:focus::-moz-focus-inner {
border: 0;
}

.c8:focus:not(:focus-visible) {
outline: none;
box-shadow: none;
}

.c8:focus:not(:focus-visible) > circle,
.c8:focus:not(:focus-visible) > ellipse,
.c8:focus:not(:focus-visible) > line,
.c8:focus:not(:focus-visible) > path,
.c8:focus:not(:focus-visible) > polygon,
.c8:focus:not(:focus-visible) > polyline,
.c8:focus:not(:focus-visible) > rect {
outline: none;
box-shadow: none;
}

.c8:focus:not(:focus-visible)::-moz-focus-inner {
border: 0;
}

.c9 {
display: inline-block;
box-sizing: border-box;
Expand Down Expand Up @@ -4999,6 +4930,71 @@ exports[`DataFilter select multiple options search 2`] = `
border: 0;
}

.c8 {
display: inline-block;
box-sizing: border-box;
cursor: pointer;
font: inherit;
-webkit-text-decoration: none;
text-decoration: none;
margin: 0;
background: transparent;
overflow: visible;
text-transform: none;
border: 2px solid #7D4CDB;
border-radius: 18px;
color: #444444;
padding: 4px 22px;
font-size: 18px;
line-height: 24px;
-webkit-transition-property: color,background-color,border-color,box-shadow;
transition-property: color,background-color,border-color,box-shadow;
-webkit-transition-duration: 0.1s;
transition-duration: 0.1s;
-webkit-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
}

.c8:focus {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}

.c8:focus > circle,
.c8:focus > ellipse,
.c8:focus > line,
.c8:focus > path,
.c8:focus > polygon,
.c8:focus > polyline,
.c8:focus > rect {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}

.c8:focus::-moz-focus-inner {
border: 0;
}

.c8:focus:not(:focus-visible) {
outline: none;
box-shadow: none;
}

.c8:focus:not(:focus-visible) > circle,
.c8:focus:not(:focus-visible) > ellipse,
.c8:focus:not(:focus-visible) > line,
.c8:focus:not(:focus-visible) > path,
.c8:focus:not(:focus-visible) > polygon,
.c8:focus:not(:focus-visible) > polyline,
.c8:focus:not(:focus-visible) > rect {
outline: none;
box-shadow: none;
}

.c8:focus:not(:focus-visible)::-moz-focus-inner {
border: 0;
}

.c18 {
display: -webkit-box;
display: -webkit-flex;
Expand Down
13 changes: 13 additions & 0 deletions src/js/components/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ const Pagination = forwardRef(
...navProps[control],
}));

// const ControlButtons = () => (
// <>
// {controls.map((control, index) => (
// /* Using index as key (as opposed to a unique id) seems to
// * help React prioritize rendering the updated controls as
// * desired. Whereas, using a unique id resulted in rendering
// * the active control with an undesired lag. */
// // eslint-disable-next-line react/no-array-index-key
// <PageControl key={index} size={size} {...control} />
// ))}
// </>
// );

return (
<StyledPaginationContainer
flex={false}
Expand Down
14 changes: 12 additions & 2 deletions src/js/components/Pagination/stories/NumberEdgePages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ export const NumberEdgePages = () => (
<Box pad="small" gap="medium">
<Box>
<Text>numberEdgePages = 2 (number of pages on start/end)</Text>
<Pagination numberItems={237} page={10} numberEdgePages={2} />
<Pagination
a11yTitle="2EdgePages"
numberItems={237}
page={10}
numberEdgePages={2}
/>
</Box>
<Box>
<Text>numberEdgePages = 0</Text>
<Pagination numberItems={237} page={10} numberEdgePages={0} />
<Pagination
a11yTitle="0EdgePages"
numberItems={237}
page={10}
numberEdgePages={0}
/>
</Box>
</Box>
// </Grommet>
Expand Down
14 changes: 12 additions & 2 deletions src/js/components/Pagination/stories/NumberMiddlePages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ export const NumberMiddlePages = () => (
<Box pad="small" gap="medium">
<Box>
<Text>numberMiddlePages = 4 (number of pages in the middle)</Text>
<Pagination numberItems={237} page={10} numberMiddlePages={4} />
<Pagination
a11yTitle="navigation-number-middle-pages-4"
numberItems={237}
page={10}
numberMiddlePages={4}
/>
</Box>
<Box>
<Text>numberMiddlePages = 5 (number of pages in the middle)</Text>
<Pagination numberItems={237} page={10} numberMiddlePages={5} />
<Pagination
a11yTitle="navigation-number-middle-pages-5"
numberItems={237}
page={10}
numberMiddlePages={5}
/>
</Box>
</Box>
// </Grommet>
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/Pagination/stories/Simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ export const Simple = () => (
<Box align="start" pad="small" gap="medium">
<Box>
<Text>Default</Text>
<Pagination numberItems={237} />
<Pagination a11yTitle="plain-text" numberItems={237} />
</Box>
<Box>
<Text>Box Props</Text>
<Pagination
a11yTitle="background-text"
numberItems={1237}
page={24}
background="brand"
Expand Down
6 changes: 3 additions & 3 deletions src/js/components/Pagination/stories/Size.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const Size = () => (
// <Grommet theme={...}>
<Box align="start" pad="small" gap="medium">
<Text>Small</Text>
<Pagination numberItems={237} size="small" />
<Pagination a11yTitle="small-text" numberItems={237} size="small" />
<Text>Medium (Default)</Text>
<Pagination numberItems={237} size="medium" />
<Pagination a11yTitle="medium-text" numberItems={237} size="medium" />
<Text>Large</Text>
<Pagination numberItems={237} size="large" />
<Pagination a11yTitle="large-text" numberItems={237} size="large" />
</Box>
// </Grommet>
);
Expand Down
63 changes: 28 additions & 35 deletions src/js/components/SelectMultiple/__tests__/SelectMultiple-test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useState } from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { render } from '@testing-library/react';
import { screen, fireEvent } from '@testing-library/dom';

import userEvent from '@testing-library/user-event';
import { axe } from 'jest-axe';
import 'jest-axe/extend-expect';
Expand Down Expand Up @@ -338,7 +340,7 @@ describe('SelectMultiple', () => {
await user.click(screen.getByRole('button', { name: /Clear All/i }));

expectPortal('test-select__drop').toMatchSnapshot();
});
}, 10000);

test('null value', () => {
const { asFragment } = render(
Expand Down Expand Up @@ -371,6 +373,7 @@ describe('SelectMultiple', () => {

test('search with select and clear', async () => {
const user = userEvent.setup();

const defaultOptions = [
'Apple',
'Orange',
Expand All @@ -383,20 +386,25 @@ describe('SelectMultiple', () => {
'Raspberry',
'Rhubarb',
];

const Test = () => {
const [options, setOptions] = useState(defaultOptions);
const [valueMultiple, setValueMultiple] = useState([]);

const handleSearch = (text: string) => {
const filtered = defaultOptions.filter((option) =>
option.toLowerCase().includes(text.toLowerCase()),
);
setOptions(filtered);
};

return (
<Grommet>
<SelectMultiple
options={options}
value={valueMultiple}
placeholder="Select"
onSearch={(text) => {
const escapedText = text.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
const exp = new RegExp(escapedText, 'i');
setOptions(defaultOptions.filter((o) => exp.test(o)));
}}
onSearch={handleSearch}
onClose={() => setOptions(defaultOptions)}
onChange={({ value }) => {
setValueMultiple(value);
Expand All @@ -405,6 +413,7 @@ describe('SelectMultiple', () => {
</Grommet>
);
};

render(<Test />);
// open drop
await user.click(screen.getByRole('button', { name: /Select/ }));
Expand All @@ -413,47 +422,31 @@ describe('SelectMultiple', () => {
// select all
await user.click(screen.getByRole('button', { name: /Select all/ }));

expect(
screen.queryByRole('option', { name: /Apple selected/ }),
).not.toBeNull();
expect(
screen.queryByRole('option', { name: /Grape selected/ }),
).not.toBeNull();
expect(
screen.queryByRole('option', { name: /Raspberry selected/ }),
).not.toBeNull();
const searchInput = screen.getByRole('searchbox', { name: /Search/ });
const optionSelectedInput = screen.queryAllByRole('option', {
name: /selected$/,
});

expect(optionSelectedInput).not.toBeNull();

// search
await user.type(
screen.getByRole('searchbox', { name: /Search/ }),
'{backspace}w',
);
await user.type(searchInput, '{backspace}w');
// select all
await user.click(screen.getByRole('button', { name: /Select all/ }));
expect(
screen.queryByRole('option', { name: /Strawberry selected/ }),
).not.toBeNull();
expect(
screen.queryByRole('option', { name: /Kiwi selected/ }),
).not.toBeNull();

expect(optionSelectedInput).not.toBeNull();

// search
await user.type(
screen.getByRole('searchbox', { name: /Search/ }),
'{backspace}b',
);
await user.type(searchInput, '{backspace}b');
// Clear
await user.click(screen.getByRole('button', { name: /Clear all/ }));
// clear search
await user.type(
screen.getByRole('searchbox', { name: /Search/ }),
'{backspace}',
);
await user.type(searchInput, '{backspace}');
expect(
screen.queryByRole('option', { name: /Grape selected/ }),
).not.toBeNull();
expect(
screen.queryByRole('option', { name: /Strawberry selected/ }),
).toBeNull();
});
}, 10000);
});