Pressing enter on a form step should not click the back button

Created on 12 July 2025, 17 days ago

Problem/Motivation

When the form step has back button first as submit, the browser considers that as the button to press when enter is pressed.

Steps to reproduce

Press enter instead of clicking next step e.g. here https://git.drupalcode.org/project/reset_password_email_otp/-/blob/1.0.x...

Proposed resolution

Simplest is probably move back buttons after the primary submit button instead of before

Remaining tasks

MR

User interface changes

Enter goes to next step

API changes

N/A

Data model changes

N/A

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @scott_euser
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia divyansh.gupta Jaipur

    Working on it!!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinodhini.e chennai

    vinodhini.e โ†’ made their first commit to this issueโ€™s fork.

  • @divyanshgupta opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia divyansh.gupta Jaipur

    The problem was occurring because the back button was defined before submit button, so correcting the order fixed the issue for me,
    Please review!!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    Thanks for the work on this! Tests are failing, but I can also see the problem with back button is on all steps, not just the one. Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia divyansh.gupta Jaipur

    Hello @scott_euser!!,
    Thanks for the feedback!
    You are correct, the issue was present on multiple steps. I have reviewed the entire form logic in EmailOTPCheck.php and confirmed that my MR addresses the button order in every relevant step.
    Like:
    -->The fix has been applied to Step 2 (fapiOtpVerificationPageTwo).
    -->The fix has been applied to Step 3 (fapiSetPasswordPageThree).
    -->Step 1 and Step 4 of the form do not contain a "Back" button, so no changes were needed there.

    Also i have made the pipeline green as there were some PHPCS related issues, also if you need changes in any particular file or step that i missed bymistake, then please guide me through it!!
    Thanks you!!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sandeep_k New Delhi

    @divyansh.gupta I have checked this MR !32 mergeable on drupal version -10.3.1-dev, the patch was applied successfully and is working fine.

    Testing Steps-

    • add module- Reset Password Email/SMS
    • configure this module from Block layout
    • Go to the page where block is configured and check- Enter key default focus was on back CTA
    • Download and apply patch- MR !32 mergeable
    • Go back to the configured page block and reverify.

    After applying the patch, the default focus of the Enter key is on the next key.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinodhini.e chennai

    @divyansh.gupta, Tested MR !32 on Drupal 11.1.7. The patch applied cleanly and and is working fine.

    Steps to Test:

    1. Install and enable the Reset Password Email/SMS module.
    2. Add the corresponding block via Block layout.
    3. After applying the patch, the Enter key correctly triggers the Next button by default.

    Thanks.

Production build 0.71.5 2024