Skip to content

Inconsistent return key behaviour when editing #10401

Open
@zorae

Description

@zorae

Problem

When editing an edition, writing something in the ID Numbers field and pressing the return key causes the ID to be added. But when trying to do the same with the Contributors or Classifications field, pressing return causes all changes to be saved and discards whatever you wrote in the field.

Reproducing the bug

  1. Go to any edition’s edit page
  2. Focus the Contributors or Classifications text input field
  3. Type any valid text
  4. With the text field still focused, press the return key on your keyboard
  • Expected behavior: The text you just wrote gets added as a contributor/classification
  • Actual behavior: The text gets discarded, but any other changes you made get saved to the edition. The return key behaves like the Save button at the bottom of the page.

Context

  • Browser (Chrome, Safari, Firefox, etc): Safari
  • OS (Windows, Mac, etc): iPadOS 18.3
  • Logged in (Y/N): Y
  • Environment (prod, dev, local): prod
    Note: My keyboard doesn’t have a dedicated enter key, so I’m not sure if the problem occurs both with return and enter keypresses.

Breakdown

Requirements Checklist

  • Pressing Enter in the Contributors or Classifications field should enter the classification and not trigger a full page save.

Related files

  • export function initClassificationValidation() {
    initJqueryRepeat();
    const dataConfig = JSON.parse(document.querySelector('#classifications').dataset.config);
    $('#classifications').repeat({
    vars: {prefix: 'edition--'},
    validate: function (data) {
    if (data.name === '' || data.name === '---') {
    return error('#classification-errors', '#select-classification', dataConfig['Please select a classification.']);
    }
    if (data.value === '') {
    const label = $('#select-classification').find(`option[value='${data.name}']`).html();
    return error('#classification-errors', '#classification-value', dataConfig['You need to give a value to CLASS.'].replace(/CLASS/, label));
    }
    $('#classification-errors').hide();
    $('#select-classification, #classification-value').val('');
    return true;
    }
    });
    }

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

Metadata

Metadata

Assignees

Labels

Affects: LibrariansIssues related to features that librarians particularly need. [managed]Lead: @cdriniIssues overseen by Drini (Staff: Team Lead & Solr, Library Explorer, i18n) [managed]Needs: Review AssigneeIssues that may have been abandoned by assigneesPriority: 4An issue, but should be worked on when no other pressing work can be done. [managed]Theme: EditingIssues related to the user editing/wiki editing experience. [managed]Type: BugSomething isn't working. [managed]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions