Skip to content

Fix: Classification dropdown overflow on mobile view#11578

Closed
KrishnaShuk wants to merge 3 commits into
internetarchive:masterfrom
KrishnaShuk:11431/fix/Overflow-edition-editor
Closed

Fix: Classification dropdown overflow on mobile view#11578
KrishnaShuk wants to merge 3 commits into
internetarchive:masterfrom
KrishnaShuk:11431/fix/Overflow-edition-editor

Conversation

@KrishnaShuk
Copy link
Copy Markdown
Contributor

Closes #11431

This PR fixes the classification dropdown overflow issue on the book edition edit page, particularly on mobile/smaller screen sizes.

Technical

CSS Changes (static/css/page-user.less):

  • Constrained #select-classification dropdown width to max-width: 300px
  • Added responsive table layout for table.classifications.identifiers on screens ≤600px
  • Table rows now use flexbox with stacked labels for better mobile readability
  • Long text values wrap correctly with word-break: break-word

Template Changes (openlibrary/templates/books/edit/edition.html):

  • Truncated long classification labels in dropdown options to 45 characters using $truncate()
  • Added data-full-label attribute to preserve full text
  • Updated JS template to use data-full-label when adding classifications to the table, ensuring full labels are displayed after selection

Testing

  1. Navigate to any book edition edit page (e.g., /books/OL23269118M/Alice%27s_adventures_in_Wonderland/edit)
  2. Use browser dev tools to simulate mobile view (e.g., Samsung Galaxy S8+, 360x740)
  3. Scroll to the "Classifications" section
  4. Verify dropdown does not overflow the screen when opened
  5. Select a classification with a long name (e.g., "Library and Archives Canada Cataloguing in Publication")
  6. Add a value and click "Add"
  7. Verify the full classification name appears in the table without horizontal overflow

Screenshot

Before

Screencast.from.2025-12-11.17-25-34.webm

After

Screencast.from.2025-12-11.17-34-45.webm

Stakeholders

@jimchamp

@KrishnaShuk
Copy link
Copy Markdown
Contributor Author

PTAL @jimchamp.

@jimchamp jimchamp self-assigned this Dec 11, 2025
@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Dec 12, 2025
Copy link
Copy Markdown
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

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

Thanks @KrishnaShuk.

We should not be truncating these values.

It's unclear to me what the data-full-label attribute does. Please explain.

Why was so much CSS needed?

<option value="">$_("Select one of many...")</option>
$for d in edition_config.classifications:
<option value="$d.name">$d.label</option>
<option value="$d.name" data-full-label="$d.label">$truncate(d.label, 45)</option>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Explain how data-full-label is used.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The value should not be truncated.

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.

  1. "data-full-label" stores the full, untruncated text of the classification. We show a shortened version in the dropdown to prevent overflow, but use this hidden attribute to display the complete name in the table after selection.

  2. If we do not truncate then the text would be overflowing in dropdown. And truncating it in the dropdown doesn't affect its text in final showcase.

image

All this is engineered to make it visually correct. If you want i can restore the changes but it would not be right in my opinion. WDYT?

Comment thread static/css/page-user.less
Comment on lines +256 to +317
#select-classification {
max-width: 300px;
width: 100%;
box-sizing: border-box;
}

table.classifications.identifiers {
width: 100%;
max-width: 100%;

td {
word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-word;
white-space: normal;
}

@media only screen and (max-width: @width-breakpoint-tablet) {
display: block;

tbody {
display: block;
width: 100%;
}

tr {
display: flex;
flex-wrap: wrap;
border-bottom: 1px solid @lightest-grey;
padding-bottom: 10px;
margin-bottom: 10px;
}

td {
display: block;
padding: 2px 0;
border: none !important;
}

td:first-child {
width: 100%;
text-align: left !important;
font-weight: bold;
color: @grey-555;
margin-bottom: 4px;
}

td:nth-child(2) {
flex: 1;
min-width: 0;
padding-right: 10px;
input {
width: 100% !important;
max-width: 100% !important;
}
}

td:last-child {
width: auto;
}
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

New CSS should be added above the import statements.

I really don't understand why so much CSS was needed here. I was able to correct the overflow by using the following:

@media only screen and (max-width: @width-breakpoint-tablet) {
  #select-classification {
    max-width: 300px;
  }
}

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.

All these css was add to make the key-value pairs in the main showcase visually appealing but some css here is overengineered. I am making a commit to correct it.

image

@jimchamp jimchamp added Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] and removed Needs: Response Issues which require feedback from lead labels Dec 22, 2025
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Dec 23, 2025
@KrishnaShuk
Copy link
Copy Markdown
Contributor Author

KrishnaShuk commented Dec 23, 2025

@jimchamp ,this is the final behavior of the latest commit:

Screencast.from.2025-12-23.13-54-54.webm

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Dec 23, 2025
@KrishnaShuk KrishnaShuk requested a review from jimchamp January 9, 2026 17:51
@KrishnaShuk
Copy link
Copy Markdown
Contributor Author

@jimchamp, The PR is ready for review.

@jimchamp
Copy link
Copy Markdown
Collaborator

Code rebased in #12773.

@jimchamp jimchamp added Needs: Staff / Internal Reviewed a PR but don't have merge powers? Use this. and removed Needs: Response Issues which require feedback from lead labels May 19, 2026
mekarpeles added a commit that referenced this pull request May 19, 2026
…#12773)

* fixed overflow issue, use standard breakpoint variable
* fix(css): rewrite classification responsive block as valid plain CSS

- Remove stray backtick left in selector after previous fix
- Restructure nested @media rule as top-level block (css-loader has no
  nesting/PostCSS support; nested rules were silently ignored)
- Replace var(--width-breakpoint-tablet) in @media condition with
  hardcoded 768px (CSS custom properties don't work in @media queries)

Addresses Copilot review comments on PR #12773.

---------

Co-authored-by: krishnaShuk <[email protected]>
Co-authored-by: Michael E. Karpeles <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Staff / Internal Reviewed a PR but don't have merge powers? Use this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overflow issue in edition editor form on mobile/tablet view

2 participants