Skip to content

added key interception to prevent form submission on enter key #10617

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

Merged
merged 4 commits into from
Jun 10, 2025

Conversation

techy4shri
Copy link
Contributor

@techy4shri techy4shri commented Mar 24, 2025

Closes #10401

  • Fixed inconsistent return key behavior in Classifications editing
  • Added proper event handling to prevent form submission
  • Made behavior consistent with ID Numbers field functionality

Technical

Modified initClassificationValidation() in edit.js:

  • Added preventDefault() to stop form submission on Enter
  • Added repeat('add') call to trigger classification addition
  • Returns false to prevent event bubbling

Testing

  1. Go to any edition's edit page
  2. Focus on Classifications input field
  3. Type valid classification details
  4. Press Enter/Return key
  5. Verify:
    Input is added as new classification
    Page does not save/reload
    Behavior matches ID Numbers field

Screenshot

Stakeholders

@cdrini

Using more specific selectors to prevent event bubbling
Added explicit return false to ensure event propagation stops
Moved the Enter key handling before the repeat initialization
@techy4shri
Copy link
Contributor Author

@cdrini really sorry for the wait but I just couldn't get this up. And the force push was accidental 😓 .

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Mar 25, 2025
@techy4shri
Copy link
Contributor Author

@cdrini @mekarpeles hello! Is there anything else this PR requires?

@mekarpeles mekarpeles added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Jun 10, 2025
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Awesome, thank you @techy4shri ! Apologies for the long delay on this one. I tested on testing, and with the added changes, works like a charm!

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 17.10%. Comparing base (2e231fa) to head (2a56491).
Report is 547 commits behind head on master.

Files with missing lines Patch % Lines
openlibrary/plugins/openlibrary/js/edit.js 20.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10617      +/-   ##
==========================================
- Coverage   17.27%   17.10%   -0.18%     
==========================================
  Files          87       91       +4     
  Lines        4845     5000     +155     
  Branches      860      870      +10     
==========================================
+ Hits          837      855      +18     
- Misses       3477     3603     +126     
- Partials      531      542      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cdrini cdrini merged commit 430f20c into internetarchive:master Jun 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Response Issues which require feedback from lead Priority: 1 Do this week, receiving emails, time sensitive, . [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent return key behaviour when editing
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy