Skip to content

Commit 430f20c

Browse files
techy4shricdrini
andauthored
added key interception to prevent form submission on enter key (#10617)
* added key interception to prevent form submission on enter key * Added event handlers for both classification input fields 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 --------- Co-authored-by: Drini Cami <cdrini@gmail.com>
1 parent 3a6883a commit 430f20c

File tree

1 file changed

+10
-0
lines changed
  • openlibrary/plugins/openlibrary/js

1 file changed

+10
-0
lines changed

openlibrary/plugins/openlibrary/js/edit.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ export function validateIdentifiers(data) {
235235
export function initClassificationValidation() {
236236
initJqueryRepeat();
237237
const dataConfig = JSON.parse(document.querySelector('#classifications').dataset.config);
238+
239+
// Prevent form submission on Enter for classification fields
240+
$('#classification-value').on('keydown', function(e) {
241+
if (e.key === 'Enter') {
242+
e.preventDefault();
243+
$('#classifications .repeat-add').trigger('click');
244+
return false;
245+
}
246+
});
247+
238248
$('#classifications').repeat({
239249
vars: {prefix: 'edition--'},
240250
validate: function (data) {

0 commit comments

Comments
 (0)
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