New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page.type has Emoji issues (UTF-8) #1096

Closed
mittermayr opened this Issue Oct 19, 2017 · 11 comments

Comments

Projects
None yet
6 participants
@mittermayr

mittermayr commented Oct 19, 2017

Two-folded issue. Some Emojis aren't typed correctly (others seem to work, randomly). And newlines are also ignored (so is keyboard.press('Enter')). The solution for newline treatment is to split the text by "\n" and then do line by line, with a page.type("#target", String.fromCharCode(13)); at the end of it.

Steps to reproduce

  • Puppeteer version: 0.13.0-alpha
  • Platform / OS version: OSX, also Debian 9

An empty HTML file, only has the following inside (it also doesn't work with the <meta charset='utf-8'> tag added, no difference):

<textarea id="theTarget"></textarea>

The code that causes the problem:

var sample = Buffer.from("8J+RuSBUb2t5byBzdHJlZXQKSmFwYW4g8J+Hr/Cfh7Ug", 'base64').toString('utf8'); await page.type("#theTarget", sample);

Even without the Buffer and decoding, if you just use the following, it won't work:
await page.type("#theTarget", "👹 Tokyo street");

What is the expected result?

👹 Tokyo street
Japan 🇯🇵

What happens instead?

 Tokyo streetJapan 

@JoelEinbinder JoelEinbinder self-assigned this Oct 23, 2017

@dosten

This comment has been minimized.

dosten commented Dec 13, 2017

Hi! Do you found a solution for this issue? I'm having the same issue.

@JoelEinbinder

This comment has been minimized.

Collaborator

JoelEinbinder commented Dec 13, 2017

It unfortunately isn't a high priority at the moment.

@JoelEinbinder

This comment has been minimized.

Collaborator

JoelEinbinder commented Dec 27, 2017

The keyboard event we are abusing to send accepts a 4 character UTF16 string, but it only uses the first character. This is causing large emoji characters to be truncated.

WebKit sends a char event for emoji, but Chromium doesn't. So we should add a new protocol method to send just an input event.

@vadimmelnicuk

This comment has been minimized.

vadimmelnicuk commented Jun 26, 2018

Any updates on the issue?

aslushnikov added a commit that referenced this issue Jul 31, 2018

fix: typing emoji (#2824)
This changes sendCharacter to use document.execCommand instead of sending a `'char'` event from the protocol. This is more aligned with how input would come in from emoji keyboards, and removes the 3ish byte limit on characters that can be sent which prevented larger emoji from being rendered correctly.

Emoji will still fail to type correctly if typing them into an iframe that is in shadow dom.

fixes #1096
@aslushnikov

This comment has been minimized.

Contributor

aslushnikov commented Jul 31, 2018

This is fixed on tip-of-tree; please give it a shot installing the @next version:

npm i puppeteer@next
@vadimmelnicuk

This comment has been minimized.

vadimmelnicuk commented Aug 1, 2018

I can confirm that the fix works for me. Thanks, @aslushnikov

@aslushnikov

This comment has been minimized.

Contributor

aslushnikov commented Aug 1, 2018

I can confirm that the fix works for me. Thanks, @aslushnikov

Credits go to @JoelEinbinder :)

@vadimmelnicuk

This comment has been minimized.

vadimmelnicuk commented Aug 2, 2018

@JoelEinbinder thanks for the emoji fix! @aslushnikov however, it seems like it wasn't included in the latest release i.e., 1.6.2. Are you planning to add the fix to 1.6.3?

@JoelEinbinder

This comment has been minimized.

Collaborator

JoelEinbinder commented Aug 2, 2018

As this wasn’t a regression, it will come in the 1.7.0 release.

@aslushnikov

This comment has been minimized.

Contributor

aslushnikov commented Aug 10, 2018

v1.7.0 is out 🎉Type your emoji now! 🔥

@obiwankenoobi

This comment has been minimized.

obiwankenoobi commented Aug 18, 2018

@aslushnikov so I thought puppeteer@next fixed my issue - but it did only on my local machine. When I deployed the app to heroku it still showing squares and not emojis. You have any idea why maybe??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment