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: becomes broken when it is placed inside a flex container. #8942

Open
3 of 6 tasks
vannizhang opened this issue Mar 14, 2024 · 6 comments
Open
3 of 6 tasks
Labels
0 - new New issues that need assignment. ArcGIS Living Atlas Issues logged by ArcGIS Living Atlas team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. calcite-components-react Issues specific to the @esri/calcite-components-react package. estimate - 3 A day or two of work, likely requires updates to tests. has workaround Issues have a workaround available in the meantime. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - low Issue is non core or affecting less that 10% of people using the library

Comments

@vannizhang
Copy link
Member

Check existing issues

Actual Behavior

The calcite-pagination component becomes broken when I have it placed inside of flex container (a div element that has display set to flex).

Here is what is an example of what I see:

image

Expected Behavior

It should just render as what we see from the example of the doc:

image

Reproduction Sample

https://codepen.io/vannizhang/pen/abxmKxV

Reproduction Steps

  1. Open the codepen link that I provided above.
  2. You should see two calcite-pagination components there.
  3. The first one looks broken as it it placed inside a flex container.

Reproduction Version

2.6.0

Relevant Info

Windows 10. Chrome 122.

Regression?

1.4.3

Priority impact

p2 - want for current milestone

Impact

Several pages of the the Living Atlas Website uses this component:

image

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-angular
  • @esri/calcite-components-react
  • @esri/calcite-design-tokens
  • @esri/eslint-plugin-calcite-components

Esri team

ArcGIS Living Atlas

@vannizhang vannizhang added 0 - new New issues that need assignment. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. needs triage Planning workflow - pending design/dev review. labels Mar 14, 2024
@github-actions github-actions bot added impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone ArcGIS Living Atlas Issues logged by ArcGIS Living Atlas team members. calcite-components Issues specific to the @esri/calcite-components package. calcite-components-react Issues specific to the @esri/calcite-components-react package. labels Mar 14, 2024
@macandcheese
Copy link
Contributor

As a workaround you can set width: 100% on the Pagination element: https://codepen.io/mac_and_cheese/pen/XWQNrMd

@macandcheese macandcheese added the has workaround Issues have a workaround available in the meantime. label Mar 15, 2024
@geospatialem geospatialem added p - low Issue is non core or affecting less that 10% of people using the library estimate - 3 A day or two of work, likely requires updates to tests. labels Mar 19, 2024
@geospatialem
Copy link
Member

Related: #8420

@geospatialem geospatialem added needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. and removed needs triage Planning workflow - pending design/dev review. labels Mar 19, 2024
@geospatialem geospatialem added this to the 2024-08-27 - Aug Release milestone Apr 3, 2024
@geospatialem geospatialem removed the needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. label Apr 3, 2024
@gpbmike
Copy link
Contributor

gpbmike commented May 31, 2024

Does anyone have a way to horizontally center the pagination while using the full container width?

edit: n/m it looks like justify-content: center; does the trick.

@nwhittaker
Copy link
Contributor

As a workaround you can set width: 100% on the Pagination element: https://codepen.io/mac_and_cheese/pen/XWQNrMd

Field Maps is also interested in a fix for this issue. @macandcheese, any idea for a workaround that allows for background, border, outline, etc… styles to hug the pagination buttons?

Observed Expected
Screenshot 2024-09-19 at 12 38 42 PM Screenshot 2024-09-19 at 12 39 31 PM

@macandcheese
Copy link
Contributor

I think this could be a limitation of the current set up of the component - without a set width it will render in the "smallest overflow configuration", so we might need to look at some adjustments there.

Because we currently set the flex display directly on Host, you can use justify-content to achieve centering, the closest you can get without a defined px width is centered within a full-width container or with a wrapping container with a set width: https://codepen.io/mac_and_cheese/pen/rNXNYyz?editors=1000

@minhiu
Copy link

minhiu commented Jan 29, 2025

Bringing this issue back to attention, as it produces lots of unwanted margin and breaks many places in our app (Business Analyst Web App team).

Currently this is our workaround, to remove the unwanted margin produced from Calcite Pagination:

  // Calcite 3.0 pagination width efficiency improvement
  // Remove when fixed from Calcite
  // Issue to track: https://github.com/Esri/calcite-design-system/issues/8942
  private _improvePaginationWidth(): void {
    // This workaround will need to force Pagination to only have 5 items or less (min 320px)
    // Since pagination sizing is based on breakpoints of width
    this._pager.style.width = "320px";
    // Create a ResizeObserver to adjust the margin-right of the pagination to remove unwanted margin
    // Since the shadowRoot has the correct width of the pagination
    this._pagerRO = new ResizeObserver((entries) => {
      const entry = entries[0];
      if (entry) {
        const { width } = entry.contentRect;
        if (width < 320) {
          this._pager.style.marginRight = `-${320 - width}px`;
        }
      }
    });
    shadowRootReady(this._pager).then((root) => {
      this._pagerRO.observe(root);
    });
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - new New issues that need assignment. ArcGIS Living Atlas Issues logged by ArcGIS Living Atlas team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. calcite-components-react Issues specific to the @esri/calcite-components-react package. estimate - 3 A day or two of work, likely requires updates to tests. has workaround Issues have a workaround available in the meantime. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - low Issue is non core or affecting less that 10% of people using the library
Projects
None yet
Development

No branches or pull requests

6 participants