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

Automatically focus input fields on certain forms #1828

Closed
Kovah opened this issue Oct 28, 2018 · 4 comments
Closed

Automatically focus input fields on certain forms #1828

Kovah opened this issue Oct 28, 2018 · 4 comments
Labels
fixed Bugs that are fixed (in a coming release).

Comments

@Kovah
Copy link

Kovah commented Oct 28, 2018

Description
This is a small UX improvement. The first or the most important input field should be automatically focused when loading a certain form. This would be incredibly helpful when enabling the "After storing, return here to create another one." option in a form. At the moment I have to click into the input field manually or use tab to navigate to the input field.

Examples where this could be added:

  • Adding new categories
  • Adding new tags

Solution
Add an autofocus HTML tag to the input fields.

@Kovah
Copy link
Author

Kovah commented Oct 28, 2018

@JC5 I would implement this if you are ok with that.
(Great app btw!)

@JC5
Copy link
Member

JC5 commented Oct 28, 2018

Sure thing, just make sure you create the PR on the develop branch. 👍

@Kovah
Copy link
Author

Kovah commented Oct 30, 2018

So, I just tried to implement this. Edited resources/views/categories/create.twig and replaced line 18 with {{ ExpandedForm.text('name', '', ['autofocus']) }}

However, autofocus only works in Safari for some reason. In Chrome and Firefox the focus is lost after a fraction of a second. I suppose that some script is blocking or interferes the expected behaviour. To make the autofocus behaviour working as expected, I would remove the autofocus tags and add this to the firefly.js file:

// Focus first visible form element in the content area
$(".content-wrapper form input:enabled:visible:first").first().focus().select()

The limitation to the content area would be needed because otherwise the search box in the sidebar is the first input field on the page.

@JC5
Copy link
Member

JC5 commented Dec 22, 2018

Most forms will now have this in the next release.

@JC5 JC5 added the fixed Bugs that are fixed (in a coming release). label Dec 22, 2018
JC5 added a commit that referenced this issue Dec 23, 2018
@JC5 JC5 closed this as completed Dec 23, 2018
hamuz pushed a commit to hamuz/firefly-iii that referenced this issue Feb 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed Bugs that are fixed (in a coming release).
Projects
None yet
Development

No branches or pull requests

2 participants