Skip to content
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

Accept Enterkey to search from homepage #243

Open
Bertware opened this issue Oct 21, 2016 · 5 comments
Open

Accept Enterkey to search from homepage #243

Bertware opened this issue Oct 21, 2016 · 5 comments

Comments

@Bertware
Copy link
Member

When entering 2 stations at the homepage search (https://irail.be/route) and pressing Enter, nothing happens.

Steps to recreate:

  • Enter 2 station names
  • Keep focus in second station field
  • Press Enter

Result:

  • Nothing happens

Expected result:

  • The search results are loaded

Handling this keypress would improve keyboard navigation on the site

@Bertware
Copy link
Member Author

Bertware commented Nov 6, 2016

Additional:
Accept input on loading homepage.

Steps to recreate:

  • Load the irail website. Language is already set, or set the language.
  • Start typing

Result:

  • Typing is ignored. The "from" field is not in focus.

Expected result:

  • I start typing in the first search field, the "from" field. This field should have focus.

Setting focus to this field would improve the user experience, and reduce the time needed to search for a train.

@Haroenv
Copy link
Member

Haroenv commented Nov 6, 2016

Second problem can probably be fixed with an autofocus attribute

@Bertware
Copy link
Member Author

Bertware commented Nov 6, 2016

First problem can probably be fixed by using a form template. This also seems a good idea to keep the HTML the way it should be. Any machine parsing the site (screen readers, but also browsers who want to apply default web actions, like enter to submit) can't see the form right now. Another option is to use javascript for this, though this does not seem like the best option.

Angular allows form tags, so there is no obvious reason to not use them. https://docs.angularjs.org/guide/forms.

I can fix them myself this weekend when I have the time, if someone has some spare time before then they should feel free to pick it up :)

Edit:
Possible javascript (quick) fix:
In PlannerCtrl.js, line 24:

  $(document).keypress(function (e) {
    if(e.which === 13){
      $("#confirm").focus();
    }
  });

Changing $("#confirm").focus(); to $("#confirm").click(); would fix this issue.

Given the fact that this javascript hook is already present, this might be the best solution in this case. I'd like a contributor backing this up before I propose this in a pull request though.

@pietercolpaert
Copy link
Member

I'm not a front-end expert here myself so wouldn't know whether this actually would indeed fix the problem. @xavez maybe you can take a look at this latest comment?

@Haroenv
Copy link
Member

Haroenv commented Nov 24, 2016

What @Bertware suggests (focus to click) is indeed a fast solution that doesn't require that much change. I agree that it should change to form though, and then the enter listener can go away.

Bertware added a commit to Bertware/hyperRail that referenced this issue Dec 6, 2016
Bertware added a commit that referenced this issue Sep 22, 2017
Set language from browser, accept enter key in planner #242 #243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants