Closed Bug 1082394 Opened 10 years ago Closed 10 years ago

during Chinese input in SSID network name EditBox, disappear all the letters of the input.

Categories

(Firefox OS Graveyard :: Gaia::Settings, defect)

defect
Not set
normal

Tracking

(b2g-v2.2 fixed)

RESOLVED FIXED
2.1 S7 (24Oct)
Tracking Status
b2g-v2.2 --- fixed

People

(Reporter: youngsu.rho, Assigned: xyuan)

References

Details

(Whiteboard: [LibGLA,TD109304,DV1, B])

Attachments

(2 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20141002030202

Steps to reproduce:

1. Settings -> Wi-Fi -> Manage networks -> Join hidden network
2. Chinese input in SSID network name EditBox


Actual results:

Composition of Chinese input when in EditBox ,
If you change the value of EditBox,
Text of the EditBox is deleted all.
Attached video 20141014_133907.mp4
* apps/settingsmadai/js/wifi.js:wifiDialog()

   // Make sure ssid length is less then 32 bytes.
   var ssid = dialog.querySelector('input[name=ssid]');
   ssid.oninput = function() {
     var ssidStr = ssid.value;
     // Non-ASCII chars in SSID will be encoded by UTF-8, and length of
     // each char might be longer than 1 byte.
     // Use encodeURIComponent() to encode ssid, then calculate correct
     // length.
     if (encodeURIComponent(ssidStr).replace(/%[\w\d]{2}/g, '1')
           .length > 32) {
       ssid.value = ssidStr.substring(0, ssidStr.length - 1);
     }
   };

When not in composition mode(English, ...), the above code works fine.
However, if during text input mode composition 
ssid.value = ssidStr.substring (0, ssidStr.length - 1); 
If the value set as shown above, all the characters are deleted.
Whiteboard: [LibGLA,TD109304,DV1, B]
Hi Vincent, Could you please kindly look into the issue ?
thank you very much !
Flags: needinfo?(vchang)
Hi EJ:
 Per f2f talk, please help check this issue.
Thanks!!
Shawn
Flags: needinfo?(ejchen)
See Also: → 1065208
Looks like a Gecko issue that when doing text composition (for Chinese input) and at the same time it got text field updated by Content JS leads to clearing the input field.

Will look into keyboard app to make sure we did not do anything strange.
Yuan, could you please also check from Gecko side for this issue?

Thanks.
Flags: needinfo?(xyuan)
Just checked this with Rudy and this "might" be Gecko's problem.

Let's wait for Gecko gurus' responses first :)
Flags: needinfo?(ejchen)
(In reply to Rudy Lu [:rudyl] from comment #5)
> Looks like a Gecko issue that when doing text composition (for Chinese
> input) and at the same time it got text field updated by Content JS leads to
> clearing the input field.
> 
> Will look into keyboard app to make sure we did not do anything strange.
> Yuan, could you please also check from Gecko side for this issue?
> 
> Thanks.

It should be gecko bug, but I don't know why now.
:masayuki, can you give any clue?

You can reproduce this bug with the following html file on either firefox desktop or B2G platform.

STR on Firefox desktop(32, 33...nightly):

1. open the html file
2. open any input method can generate composition text.
3. select the input and start typing with composition text.

expected:
The value of the input field remains as 'good' during composition.

actual:
The value of the input field is cleared during composition.
--------------------------------------
<html>
<body>
<input id="i" type="text" value="good">
<script>
document.getElementById("i").oninput = function() {
    this.value = "good";
}
</script>
</body>
</html>
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(xyuan) → needinfo?(masayuki)
(In reply to Yuan Xulei [:yxl] from comment #7)
> 1. open the html file
> 2. open any input method can generate composition text.
> 3. select the input and start typing with composition text.
> 
> expected:
> The value of the input field remains as 'good' during composition.
> 
> actual:
> The value of the input field is cleared during composition.
> --------------------------------------
> <html>
> <body>
> <input id="i" type="text" value="good">
> <script>
> document.getElementById("i").oninput = function() {
>     this.value = "good";
> }
> </script>
> </body>
> </html>

What should occur at setting value during composition is not defined any spec.

Our behavior is:

1. Call nsIWidget::NotifyIME(REQUEST_TO_COMMIT) via IMEStateManager and TextComposition for forcibly committing composition.
2. Overwrite the value as expected by the setter.

This isn't a bug of Gecko. It's designed so at least for now. Any editors shouldn't touch during composition. InputEvent.isComposing is useful for checking if an input event is fired by composition or another reason.

FYI: There is a known issue. IME on B2G completely ignores nsIWidget::NotifyIME() :-( See bug 917323.
Flags: needinfo?(masayuki)
See following document for InputEvent.isComposing:
https://developer.mozilla.org/en-US/docs/Web/API/InputEvent

It's available 31 and later.
Looks like not a bug I can fix.
Flags: needinfo?(vchang)
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #9)
> See following document for InputEvent.isComposing:
> https://developer.mozilla.org/en-US/docs/Web/API/InputEvent
> 
> It's available 31 and later.
Masayuki, thank you. 

Then we could fix this bug by checking isComposing attribute:

<html>
<body>
<input id="i" type="text" value="good">
<script>
document.getElementById("i").oninput = function(evt) {
  if (!evt.isComposing) {
    this.value = "good";
  }
}
</script>
</body>
</html>
Assignee: nobody → xyuan
I share the workaround patch using isComposing member.
But, entering words disappeared when Composition was finished.
So, you should need to notify user why words were disappeared.
(In reply to Youngsu Rho from comment #12)
> Created attachment 8509972 [details] [diff] [review]
> gaia_apps_settings_js_wifi.js.patch
> 
> I share the workaround patch using isComposing member.
> But, entering words disappeared when Composition was finished.
> So, you should need to notify user why words were disappeared.

Thanks. Good idea to notify user of truncating input. We need UX input for that and may add this feature later.
Hello Vincent, 
could you please kindly help review the patch for us ? Thanks !
Flags: needinfo?(vchang)
Hi EJ, could you please kindly help us review the patch ?

remove no on Vicent Chang
Flags: needinfo?(vchang)
Attachment #8509972 - Attachment is obsolete: true
Attachment #8509972 - Flags: review?(ejchen)
Attachment #8510128 - Flags: review?(rlu)
Attachment #8510128 - Attachment is patch: true
Attachment #8510128 - Attachment mime type: text/x-github-pull-request → text/plain
Comment on attachment 8510128 [details] [diff] [review]
Don't change input value during composition.

r=me with some nits to be addressed.
Also offline-discussed this with ej, so should be good to go.
Attachment #8510128 - Flags: review?(rlu) → review+
Rudy, thanks. I just updated the pull request to address all the comments.
Keywords: checkin-needed
Master: https://github.com/mozilla-b2g/gaia/commit/e9e132e0b05ff4cd758f67b34ec6bad663d2a78b
Status: NEW → RESOLVED
Closed: 10 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 2.1 S7 (24Oct)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: