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

[Pagination] getItemAriaLabel is called with a wrong page type: end-ellipsis #39063

Closed
2 tasks done
muhammetsait opened this issue Sep 20, 2023 · 3 comments · Fixed by #39390
Closed
2 tasks done

[Pagination] getItemAriaLabel is called with a wrong page type: end-ellipsis #39063

muhammetsait opened this issue Sep 20, 2023 · 3 comments · Fixed by #39390
Labels
bug 🐛 Something doesn't work component: pagination This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. package: material-ui Specific to @mui/material typescript

Comments

@muhammetsait
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
https://codesandbox.io/s/laughing-shamir-jncgvx?file=/src/App.tsx
Steps:

  1. Pass getItemAriaLabel to Pagination component.
  2. The total number of pages need to be high enough to render the ellipsis

Current behavior 😯

getItemAriaLabel is called with type start-ellipsis or end-ellipsis

Expected behavior 🤔

Don't call getItemAriaLabel for the ellipsis items, or fix the parameter type definition

Context 🔦

No response

Your environment 🌎

No response

@muhammetsait muhammetsait added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 20, 2023
@zannager zannager added the component: pagination This is the name of the generic UI component, not the React module! label Sep 20, 2023
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Oct 10, 2023

Thank you for the report. We need to correct the type parameter of getItemAriaLabel. By default, we don't apply the aria-label to the ellipsis items, but we provide the type for the ellipsis in case a custom aria-label is used with getItemAriaLabel. Here's the fix:

--- a/packages/mui-material/src/Pagination/Pagination.d.ts
+++ b/packages/mui-material/src/Pagination/Pagination.d.ts
@@ -41,16 +41,12 @@ export interface PaginationProps
    * This is important for screen reader users.
    *
    * For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
-   * @param {string} type The link or button type to format ('page' | 'first' | 'last' | 'next' | 'previous'). Defaults
to 'page'.
+   * @param {string} type The link or button type to format ('page' | 'first' | 'last' | 'next' | 'previous' | 'start-el
lipsis' | 'end-ellipsis'). Defaults to 'page'.
    * @param {number} page The page number to format.
    * @param {bool} selected If true, the current page is selected.
    * @returns {string}
    */
-  getItemAriaLabel?: (
-    type: 'page' | 'first' | 'last' | 'next' | 'previous',
-    page: number,
-    selected: boolean,
-  ) => string;
+  getItemAriaLabel?: (type: UsePaginationItem['type'], page: number, selected: boolean) => string;
   /**
    * Render the item.
    * @param {PaginationRenderItemParams} params The props to spread on a PaginationItem.

Would you to create a pull request to fix this?

@ZeeshanTamboli ZeeshanTamboli changed the title getItemAriaLabel is called with a wrong page type: end-ellipsis [Pagination] getItemAriaLabel is called with a wrong page type: end-ellipsis Oct 10, 2023
@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. typescript package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 10, 2023
@imSanko
Copy link

imSanko commented Oct 10, 2023

Can I try to work this issue @ZeeshanTamboli

@ZeeshanTamboli
Copy link
Member

@imSanko Feel free to.

Simer13 added a commit to Simer13/material-ui that referenced this issue Oct 11, 2023
This gives a solution to fix mui#39063 issue to correct the type parameter of getItemAriaLabel in the Pagination section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: pagination This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants