After a new item is created, focus should be set on the input element where the item's value is typed in or on the key input if shown. The attached patch does this for the Add item button and for the plus sign after each item.

Comments

quicksketch’s picture

The current behavior is intentional, as it allows you to create multiple items at the same time. Say you were creating a list and expected to have 20 entries, keeping the focus on the add link makes it so you can repeatedly add more choices.

However I see the value in what you're suggesting, since it's probably more helpful for mouse-users who can already just click multiple times since the mouse stays in the same position. The current behavior is intended to make that same convenience available for people navigating by keyboard alone. I'll have to give this a shot and see how beneficial the new behavior is versus how much it inconveniences keyboard users.

quicksketch’s picture

Never mind, after testing this I agree that the new approach is MUCH better. Especially after trying to navigate back and forth between the textfields and the add/remove icons. I found that using the keyboard to *remove* a row gives you a rather unfortunate experience because it doesn't give focus to anything on the page, meaning tabbing-through the items on the page starts at the top again. However that problem exists both before and after this patch, so let's not block this approach because of that issue.

I'd like to clean up the selector a little bit (it seems to me to be overly specific) to help it weather changes in the markup, but the patch provides great functionality.

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new1.28 KB

This patch provides the same behavior but makes things work a bit more cleanly. Rather than specifically looking for a key or value textfield, it just looks for the first visible textfield. It's less verbose and is less likely to break with markup changes. Committed to both branches.

quicksketch’s picture

StatusFileSize
new1.32 KB

While testing this on Drupal 6, I found that jQuery 1.2 and 1.3 don't have support for the .first() operation. So I altered the code to use the :first CSS selector instead, which works on both D6 and D7.

liam morland’s picture

Great. Thanks.

Status: Fixed » Closed (fixed)

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