#23054 closed defect (bug) (fixed)
Cursor position after editing media library attachment details
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.5.1 | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
After editing the caption of an attachment in the media library insert dialog the cursor jumps to the wrong position when you click in another field.
Steps to reproduce:
- create/edit a post
- open the "insert media" dialog
- select an image
- enter text in the "caption" field
- click in the "alt text" (or "description") field
Expected behavior:
- the cursor should be in the clicked field, ready to accept text
Instead:
- the cursor jumps to the beginning of the text in the "caption" field
I confirmed this behavior with three separate installations on different servers and with the default theme, no plugins activated.
Attachments (3)
Change History (10)
#4
@
13 years ago
It looks like the [data-setting] change events call updateSetting() which then saves the model, which then re-renders the view.
If we could add a click event, we could record the field that was clicked and add the focus there after the view re-renders.
Unfortunately you can't just add a click event because the change event fires when the focus is lost (re-rendering the view), before the click event can fire.
23054.diff adds a 50ms delay (which is a bit of a hack) allowing the click event to fire before the modal is saved and the view is re-rendered.
I also removed the 'change [data-setting]' event. It was breaking the spinner/save functionality (and I can't really figure out why it's there - hopefully someone can enlighten me).
As far as I can tell, this patch works, but it's hacky, and could very likely be improved.
#5
@
13 years ago
- Keywords has-patch commit added; needs-patch removed
23054.3.diff is lovely.
This only affected titles and captions because those fields were re-rendered in case there were describable elements ("Describe this file" / "Caption this image"), as we would need to sync those fields. We can skip the re-render whenever the attachment view being rendered has the same value as the model, which would be the case for the view being edited. And if there's only one visible view, then there's no re-rendering at all.
This might also render some of our brute-force make-tabbing-work code obsolete, which we can look into during 3.6.
Confirmed. Clicking another field after editing Caption causes the spinner and the "Saved" message to appear, but the cursor stays in the previous field.
Only happens with Title and Caption fields. Editing Alt Text and Description seems to work correctly.
The results are a bit inconsistent with different browsers: