Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Issue 660 - Increase page_current and page_count fields size to accommodate larger numbers#819

Merged
Marc-Andre-Rivet merged 4 commits intodevfrom
660-page-field
Aug 21, 2020
Merged

Issue 660 - Increase page_current and page_count fields size to accommodate larger numbers#819
Marc-Andre-Rivet merged 4 commits intodevfrom
660-page-field

Conversation

@Marc-Andre-Rivet
Copy link
Copy Markdown
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Aug 20, 2020

Closes #660

  • Dynamically determine the width of the page_current and page_count fields based on the number of pages (1ch/char + 1)
  • Reactively resize the page_current field for the case where no page_count is defined (e.g. page_action='custom' without the server returning page_count

@Marc-Andre-Rivet Marc-Andre-Rivet changed the title Issue 660 - Current page field is too small for large page number Issue 660 - Increase page_current and page_count fields size to accommodate larger numbers Aug 20, 2020
@Marc-Andre-Rivet Marc-Andre-Rivet marked this pull request as ready for review August 20, 2020 21:00
&:focus {
outline: none;
border: none;
width: 7ch;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1ch is the space required to display a 0 - since there's some padding/margins 7ch displays 6 chars for sure, maybe 7 depending on the font-size, etc.

page_action='custom'
page_count={999999}
page_current={987654}
page_size={10}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple visual test to see that numbers with 6 digits are displayed correctly.

@alexcjohnson
Copy link
Copy Markdown
Collaborator

This seems reasonable, but I wonder if these need to be fixed widths? Is it problematic to let them grow with their content?

@Marc-Andre-Rivet
Copy link
Copy Markdown
Contributor Author

Marc-Andre-Rivet commented Aug 21, 2020

Inputs are weird beast and can't typically made to automatically grow with content, unlike other elements.

Typically this can be worked around by using something like <div contenteditable /> as the div will allow resizing - this won't automatically validate for numbers, etc. like the current field and you can actually start writing actual html into the div... I could also look into wrapping the input, position it absolutely + take all the available space, and use an identically styled span or div with the same content to force a resize - never used that method but I don't see any reason why it wouldn't work. I don't have a problem spending more time tweaking this into a more "dynamic" solution if we feel like it.

@alexcjohnson
Copy link
Copy Markdown
Collaborator

Ah right, number validation and other bits of <input> behavior are nice. What if we size both the input and the total page count to fixed widths but based on the number of digits in page_count instead of globally constant?

@Marc-Andre-Rivet
Copy link
Copy Markdown
Contributor Author

Marc-Andre-Rivet commented Aug 21, 2020

Modified the proposed fix to:

  • apply a min-width of the maximum between 4ch or '{}ch".format(len(page_count)+1)
  • dynamically resize the input with the current value by using a shadow div and absolute positioning to support the page_action='custom' case where page_count might be unkown

image

image

pagination-large-no-count

Copy link
Copy Markdown
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! 💃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Current page number field not large enough for large tables

2 participants