Closed
Bug 1059163
Opened 10 years ago
Closed 10 years ago
Clearing innerHTML of contenteditable with keyboard focus does not reset keyboard state
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
FIXED
mozilla35
People
(Reporter: janjongboom, Assigned: janjongboom)
Details
Attachments
(2 files, 5 obsolete files)
2.38 KB,
application/zip
|
Details | |
7.37 KB,
patch
|
janjongboom
:
review+
|
Details | Diff | Splinter Review |
Does not happen on Flame 1.4, but does happen on Dolphin 1.4.
Have some HTML:
<div id="text" contenteditable style="width: 50vw; font-size: 1.3rem; height: 40vw; border: solid 1px black"></div>
<div contenteditable id="say">Click me</button>
Have some JS:
document.querySelector('#say').onclick = function(e) {
e.preventDefault();
document.querySelector('#text').innerHTML = '';
document.querySelector('#text').focus();
}
Type in the contenteditable: "Fhqv" and press 'Click me'.
Expected:
- Keyboard suggest panel is empty
Actual:
- Keyboard suggestions are there
- Keyboard state thinks it's never cleared
- Keyboard goes into caps lock state and can't easily recover
Have to blur & focus to regain this.
Assignee | ||
Comment 1•10 years ago
|
||
Assignee | ||
Comment 2•10 years ago
|
||
So after clearing the contenteditable, the state in the inputcontext is incorrect, as it keeps selectionstart & selectionend at the old values. This is a gecko bug.
Anyway, don't have time to rush a gecko bug out, so here's a quick workaround that at least solves the problem in ConnectA2 for Dolphin 1.4. We'll take it in our own build.
Assignee: nobody → janjongboom
Attachment #8479822 -
Flags: review?(rlu)
Assignee | ||
Comment 3•10 years ago
|
||
:yxl, any clue what happens on gecko side that this doesn't happen on Flame?
Flags: needinfo?(xyuan)
Comment 4•10 years ago
|
||
I don't know why and cannot find a dolphin device to test this bug today. May find a device tomorrow.
I can reproduce this bug with v2.0 and v2.1 as well.
Flags: needinfo?(xyuan)
Assignee | ||
Comment 5•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(janjongboom)
Assignee | ||
Comment 6•10 years ago
|
||
For master I found a bug in the selection events... See bug 1060579.
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(janjongboom)
Comment 7•10 years ago
|
||
Comment on attachment 8479822 [details] [review]
This resolves the problem Gaia side
I don't have a dolphin either, and will ask around to borrow one.
Before that, could you please help explain why this workaround is needed?
If I understand correctly, the activate() method would be triggered after you refocus on the input field and this has nothing to do with selectionchange.
So, we should get correct selectionStart in activate(), no need to override its value.
If the selectionStart would be incorrect in activate, then this is a issue that we should fix at Gecko side.
Attachment #8479822 -
Flags: review?(rlu) → feedback-
Comment 8•10 years ago
|
||
BTW, I could not repro this issue with 2.0 and master (2.1), did I miss anything?
Assignee | ||
Comment 9•10 years ago
|
||
(In reply to Rudy Lu [:rudyl] from comment #7)
> Comment on attachment 8479822 [details] [review]
> This resolves the problem Gaia side
>
> I don't have a dolphin either, and will ask around to borrow one.
> Before that, could you please help explain why this workaround is needed?
>
> If I understand correctly, the activate() method would be triggered after
> you refocus on the input field and this has nothing to do with
> selectionchange.
> So, we should get correct selectionStart in activate(), no need to override
> its value.
>
> If the selectionStart would be incorrect in activate, then this is a issue
> that we should fix at Gecko side.
Yeah, but selectionStart is wrong in the activate call due to bug 1060579. We needed a quick fix for release without changing Gecko. I think in retrospect we shouldn't land this in upstream.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Comment 10•10 years ago
|
||
(In reply to Jan Jongboom [:janjongboom] (Telenor) from comment #9)
> (In reply to Rudy Lu [:rudyl] from comment #7)
> > Comment on attachment 8479822 [details] [review]
> > This resolves the problem Gaia side
> >
> > I don't have a dolphin either, and will ask around to borrow one.
> > Before that, could you please help explain why this workaround is needed?
> >
> > If I understand correctly, the activate() method would be triggered after
> > you refocus on the input field and this has nothing to do with
> > selectionchange.
> > So, we should get correct selectionStart in activate(), no need to override
> > its value.
> >
> > If the selectionStart would be incorrect in activate, then this is a issue
> > that we should fix at Gecko side.
>
> Yeah, but selectionStart is wrong in the activate call due to bug 1060579.
> We needed a quick fix for release without changing Gecko. I think in
> retrospect we shouldn't land this in upstream.
>
> *** This bug has been marked as a duplicate of bug 1060579 ***
I believe it is not the same with bug 1060579. We haven't landed selection listener related code on v1.4 and v2.0. So fixing selection listener should not fix this totally.
In forms.js, we have an editor observer to monitor the content changes:
https://github.com/mozilla/gecko-dev/blob/2fbbb04a62fbcbbaed5291510f45cb4f327c1800/dom/inputmethod/forms.js#L330
When clearing innerHTML, we should get a notification and update input state for the keyboard app.
But for some unknown reason, we fail to get correct selectionStart value when updating input state.
Assignee | ||
Comment 11•10 years ago
|
||
(In reply to Yuan Xulei [:yxl] from comment #10)
> (In reply to Jan Jongboom [:janjongboom] (Telenor) from comment #9)
> > (In reply to Rudy Lu [:rudyl] from comment #7)
> > > Comment on attachment 8479822 [details] [review]
> > > This resolves the problem Gaia side
> > >
> > > I don't have a dolphin either, and will ask around to borrow one.
> > > Before that, could you please help explain why this workaround is needed?
> > >
> > > If I understand correctly, the activate() method would be triggered after
> > > you refocus on the input field and this has nothing to do with
> > > selectionchange.
> > > So, we should get correct selectionStart in activate(), no need to override
> > > its value.
> > >
> > > If the selectionStart would be incorrect in activate, then this is a issue
> > > that we should fix at Gecko side.
> >
> > Yeah, but selectionStart is wrong in the activate call due to bug 1060579.
> > We needed a quick fix for release without changing Gecko. I think in
> > retrospect we shouldn't land this in upstream.
> >
> > *** This bug has been marked as a duplicate of bug 1060579 ***
> I believe it is not the same with bug 1060579. We haven't landed selection
> listener related code on v1.4 and v2.0. So fixing selection listener should
> not fix this totally.
>
> In forms.js, we have an editor observer to monitor the content changes:
> https://github.com/mozilla/gecko-dev/blob/
> 2fbbb04a62fbcbbaed5291510f45cb4f327c1800/dom/inputmethod/forms.js#L330
>
> When clearing innerHTML, we should get a notification and update input state
> for the keyboard app.
> But for some unknown reason, we fail to get correct selectionStart value
> when updating input state.
Good point. I still think it is somewhat related, because how we get the selection is also updated through the private selection API, and that doesn't emit an event, thus not updating that state.
Flags: needinfo?(xyuan)
Comment 12•10 years ago
|
||
(In reply to Jan Jongboom [:janjongboom] (Telenor) from comment #11)
...
>
> Good point. I still think it is somewhat related, because how we get the
> selection is also updated through the private selection API, and that
> doesn't emit an event, thus not updating that state.
That may be the root cause.
Flags: needinfo?(xyuan)
Updated•10 years ago
|
Component: Gaia::Keyboard → DOM: Device Interfaces
Product: Firefox OS → Core
Assignee | ||
Comment 13•10 years ago
|
||
Nice and clean
Attachment #8479822 -
Attachment is obsolete: true
Attachment #8481469 -
Attachment is obsolete: true
Attachment #8493699 -
Flags: review?(xyuan)
Assignee | ||
Comment 14•10 years ago
|
||
Only downside I have is that the mutation observer also triggers on things like inserting newlines (because <br>), but we have dirty checking before we send it back so no perf impact I think.
Comment 15•10 years ago
|
||
Comment on attachment 8493699 [details] [diff] [review]
bug1059163.patch
Review of attachment 8493699 [details] [diff] [review]:
-----------------------------------------------------------------
Why not use EditAction to get content mutation notification?
https://github.com/mozilla/gecko-dev/blob/27b927d770836cdd6f2579df7b40f7edc4f6990a/dom/inputmethod/forms.js#L332
When the text of a content editable is changed, EditAction() will be called. So we may not need _focusContentObserver to do the same job.
::: dom/inputmethod/mochitest/test_bug1059163.html
@@ +32,5 @@
> +
> +function runTest() {
> + let im = navigator.mozInputMethod;
> +
> + im.oninputcontextchange = function() {
This oninputcontextchange handler is useless. You get non null gContext within the handler, but never use it elsewhere.
@@ +55,5 @@
> + document.body.appendChild(app);
> + app.addEventListener('mozbrowserloadend', function() {
> + let mm = SpecialPowers.getBrowserFrameMessageManager(app);
> +
> + let timeout = setTimeout(function() {
Remove this setTimeout. Let the mochitest test framework to handle the test timeout issue.
Attachment #8493699 -
Flags: review?(xyuan)
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(janjongboom)
Comment 16•10 years ago
|
||
Seems this is no longer a Dolphin/1.4 only feature?
Summary: [Dolphin][1.4] Clearing innerHTML of contenteditable with keyboard focus does not reset keyboard state → Clearing innerHTML of contenteditable with keyboard focus does not reset keyboard state
Assignee | ||
Comment 17•10 years ago
|
||
(In reply to Yuan Xulei [:yxl] from comment #15)
> Comment on attachment 8493699 [details] [diff] [review]
> bug1059163.patch
>
> Review of attachment 8493699 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Why not use EditAction to get content mutation notification?
> https://github.com/mozilla/gecko-dev/blob/
> 27b927d770836cdd6f2579df7b40f7edc4f6990a/dom/inputmethod/forms.js#L332
>
> When the text of a content editable is changed, EditAction() will be called.
> So we may not need _focusContentObserver to do the same job.
No. EditAction does not fire either when clearing through innerHTML.
Flags: needinfo?(janjongboom)
Assignee | ||
Comment 18•10 years ago
|
||
Attachment #8493699 -
Attachment is obsolete: true
Attachment #8495988 -
Flags: review?(xyuan)
Assignee | ||
Comment 19•10 years ago
|
||
Comment on attachment 8495988 [details] [diff] [review]
bug1059163_v2.patch
Redirecting as :yxl is on PTO.
Attachment #8495988 -
Flags: review?(xyuan) → review?(fabrice)
Assignee | ||
Comment 20•10 years ago
|
||
Comment on attachment 8495988 [details] [diff] [review]
bug1059163_v2.patch
Let's do the re-assign dance again
Attachment #8495988 -
Flags: review?(fabrice) → review?(xyuan)
Updated•10 years ago
|
Attachment #8495988 -
Flags: review?(xyuan) → review+
Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Keywords: checkin-needed
Comment 22•10 years ago
|
||
sorry had to back this out again since the new test caused frequent test failures like https://treeherder.mozilla.org/ui/logviewer.html#?job_id=2881587&repo=mozilla-inbound
Assignee | ||
Comment 23•10 years ago
|
||
Added some safeguards in the tests, let's see what happens. Try @ https://tbpl.mozilla.org/?tree=Try&rev=803449c7ed5c
Attachment #8495988 -
Attachment is obsolete: true
Attachment #8502422 -
Flags: review+
Assignee | ||
Comment 24•10 years ago
|
||
Uploaded wrong patch. Try @ https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=587f6b16f455
Attachment #8502422 -
Attachment is obsolete: true
Attachment #8502470 -
Flags: review+
Assignee | ||
Comment 25•10 years ago
|
||
So previous try run doesn't have the error anymore. Let's do another one to be sure. https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=b8559fc78b37
Assignee | ||
Comment 26•10 years ago
|
||
Didn't see the test failures anymore, so let's give it another shot at landing!
Keywords: checkin-needed
Comment 27•10 years ago
|
||
Flags: in-testsuite+
Keywords: checkin-needed
Comment 28•10 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 10 years ago → 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
You need to log in
before you can comment on or make changes to this bug.
Description
•