Problem/Motivation

When typing into the filter field on the browser, often a user will press the "enter" key vs waiting for the ajax action to return. Since this a form, doing so ends up reloading the browser.

Steps to reproduce

  1. Open the browser.
  2. Type into the filter field and immediately press "enter"

Proposed resolution

The enter key should be either captured and simply perform the action, or be ignored so the browser doesn't completely reload.

Remaining tasks

  • Write a patch to compensate for the enter key being pressed.

User interface changes

n/a

API changes

n/a

Data model changes

n/a

CommentFileSizeAuthor
#4 3279259-disable_enter-4.patch1.07 KBytsurk

Comments

devkinetic created an issue. See original summary.

ytsurk’s picture

I'll have a look at this.

ytsurk’s picture

Assigned: Unassigned » ytsurk
ytsurk’s picture

Assigned: ytsurk » Unassigned
Status: Active » Needs review
StatusFileSize
new1.07 KB

Here a patch disabling the submission of the entity browser form. The form also will no longer submit if, fe. the quick-edit button is active, a media item selected and then enter is pressed.

  • ytsurk committed 98f3bbe6 on 2.1.x
    Issue #3279259 by ytsurk: Disable/Capture the enter key on the Filter...

  • ytsurk committed a4c9574c on 2.0.x
    Issue #3279259 by ytsurk: Disable/Capture the enter key on the Filter...
ytsurk’s picture

Version: 2.0.2 » 2.1.x-dev
Status: Needs review » Fixed

Backported to 2.0.x

ytsurk’s picture

Status: Fixed » Needs work

Ups - I introduced a regression here.

The patch was not well tested, Sorry.

Undoing my changes here for now.

  • ytsurk committed 738ba5d3 on 2.1.x
    Issue #3279259 by ytsurk: Reverts due a regression bug - Disable/Capture...

  • ytsurk committed a461ccf8 on 2.0.x
    Issue #3279259 by ytsurk: Reverts due a regression bug - Disable/Capture...

  • rang501 committed 1d1453c5 on 2.1.x
    Issue #3279259 by ytsurk: Disable/Capture the enter key on the Filter...
rang501’s picture

Status: Needs work » Needs review

So I took a look at it and the problem was with keyup event, it triggered in all keyup events.

I commited a fix that checks event itself inside keyup handler. Seems to solve the issue and adding media also works.

ytsurk’s picture

Status: Needs review » Needs work

For me in firefox the reload does still happen when I press enter in the search field ("filter").

rang501’s picture

I could take a look at it over the weekend if I have time.

  • rang501 committed 6ebbd660 on 2.1.x
    Issue #3279259 Add keydown event to prevent form submit
    
rang501’s picture

I found the issue - it seems that the keydown was triggering the form submission, so I added separate keydown event that will prevent enter key from submitting the form.
Works both in Chrome and Firefox.

ytsurk’s picture

Status: Needs work » Needs review

I can confirm this now works. Thanks rang501.

ytsurk’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.