Closed
Bug 513299
Opened 15 years ago
Closed 15 years ago
Switching windows causes all text in single-line textfield to be reselected
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: neil, Assigned: enndeakin)
Details
(Keywords: regression)
Attachments
(1 file, 1 obsolete file)
20.44 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
Steps to reproduce problem:
1. Start typing in a textfield; generally I find the Error Console to be the one whose buggy behaviour is most likely to annoy me
2. Switch to another window (in any application) e.g. to copy some text
3. Switch back so you can paste it in at the caret
Expected result: able to paste text in at caret
Actual results: caret position lost because all text is now selected
This doesn't happen on 1.9.1, so I'd like to blame focus refactoring.
Assignee | ||
Comment 1•15 years ago
|
||
Don't see this bug myself.
Reporter | ||
Comment 2•15 years ago
|
||
It depends on how focus was originally moved to the textfield. When the window is activated it does not reset the last focus method so if that was by key (or by move focus) then the text field gets reselected.
Assignee | ||
Comment 3•15 years ago
|
||
So it looks like we need to distinguish between a focus caused by a window raise and otherwise. Alternatively, fm->GetLastFocusMethod could instead return some cached value that is always set. That would require an alternate way of retrieving the focus method per window though.
Assignee | ||
Comment 4•15 years ago
|
||
Assignee: nobody → enndeakin
Status: NEW → ASSIGNED
Assignee | ||
Updated•15 years ago
|
Attachment #400113 -
Flags: superreview?(neil)
Attachment #400113 -
Flags: review?(Olli.Pettay)
Assignee | ||
Comment 5•15 years ago
|
||
Comment on attachment 400113 [details] [diff] [review]
add back nsFocusEvent with a flag to indicate that the window was raised
Try server shows no issues with this patch
Reporter | ||
Updated•15 years ago
|
Attachment #400113 -
Flags: superreview?(neil) → superreview+
Comment 6•15 years ago
|
||
Comment on attachment 400113 [details] [diff] [review]
add back nsFocusEvent with a flag to indicate that the window was raised
You need to add nsFocusEvent to nsDOMEvent::DuplicatePrivateData
>@@ -1776,21 +1776,24 @@ nsHTMLInputElement::PostHandleEvent(nsEv
> }
>
> if (NS_SUCCEEDED(rv)) {
> if (nsEventStatus_eIgnore == aVisitor.mEventStatus) {
> switch (aVisitor.mEvent->message) {
>
> case NS_FOCUS_CONTENT:
> {
>+ // see if we should select the contents of the textbox. This happens
>+ // for text and password fields when the field was focused by the
>+ // keyboard or a navigation, the platform allows it, and it wasn't
>+ // just because we raised a window.
> nsIFocusManager* fm = nsFocusManager::GetFocusManager();
> if (fm && (mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_PASSWORD) &&
>+ !(static_cast<nsFocusEvent *>(aVisitor.mEvent))->mFromRaise &&
> SelectTextFieldOnFocus()) {
What if someone creates focus event using
var e = document.createEvent("Event");
e.initEvent("focus", false, false);
inputElement.dispatchEvent(e);
That event isn't nsFocusEvent, but nsEvent.
You probably need to change nsDOMEvent::SetEventType so that
NS_FOCUS/BLUR_CONTENT is set only to nsFocusEvent.
Please test accessing focus event after event dispatch.
Attachment #400113 -
Flags: review?(Olli.Pettay) → review-
Assignee | ||
Comment 7•15 years ago
|
||
Attachment #400113 -
Attachment is obsolete: true
Attachment #401062 -
Flags: review?(Olli.Pettay)
Comment 8•15 years ago
|
||
Comment on attachment 401062 [details] [diff] [review]
updated patch
Sorry about the delay!
Attachment #401062 -
Flags: review?(Olli.Pettay) → review+
Assignee | ||
Comment 9•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•