LaunchpadFormView.focusedElementScript should handle field prefix itself

Bug #57621 reported by Francis J. Lacoste
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Medium
James Henstridge

Bug Description

The LaunchpadFormView has some support for setting the focus on a particular widget.

The API is to have that widget specified using the focused_element_id. But if we specify the name of the field directly, it won't work. We need to add the default prefix to make it work. It would be better if that prefix handling was done by focusedElementScript() instead.

In other words, I expect the following to

  focused_element_id = 'title'

render

  setFocusByElementId('field.title')

when the form prefix is set to field.

Revision history for this message
James Henstridge (jamesh) wrote :

That would be pretty weird behaviour given the attribute is called focused_element_id.

It would make sense if the attribute was focused_field or focused_widget though. Maybe one of those would be better.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

That's a good point. I suggest renaming the attribute to focused_widget since that is what the focus is on.

Revision history for this message
James Henstridge (jamesh) wrote :

We can probably simplify the javascript a bit further too, moving the "focus first widget with error" code to the server side. I'll look at making this change.

Changed in launchpad:
assignee: nobody → jamesh
status: Unconfirmed → Confirmed
Revision history for this message
James Henstridge (jamesh) wrote :

One place where this idea falls down is radio button groups. There isn't actually an element with an ID matching the widget name (they are of the form "$name.0", "$name.1", ...).

Revision history for this message
James Henstridge (jamesh) wrote :

I've put a branch up for review. You can set initial_focus_widget to a widget name now.

The JS code should also handle the case where the named widget is a radio button group.

Changed in launchpad:
status: Confirmed → In Progress
Revision history for this message
Diogo Matsubara (matsubara) wrote :

Changing importance since it's fixed and up for review.

Changed in launchpad:
importance: Untriaged → Medium
Revision history for this message
James Henstridge (jamesh) wrote :

Fix merged as r4003

Changed in launchpad:
status: In Progress → Fix Committed
Revision history for this message
James Henstridge (jamesh) wrote :

Fix rolled out today.

Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.