WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 16 months ago

#42234 closed defect (bug) (fixed)

New tag should be added at the `keypress` event instead of `keyup`

Reported by: miyauchi Owned by: SergeyBiryukov
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Taxonomy Keywords: has-patch has-screenshots
Focuses: Cc:

Description (last modified by SergeyBiryukov)

keyup event will be always fired when Japanese kanji will be submitted.
The event should be changed from keyup to keypress.

Related: #42233

Attachments (4)

42234.diff (534 bytes) - added by miyauchi 3 years ago.
after.gif (113.8 KB) - added by miyauchi 3 years ago.
It's a screencast to reproduce this problem.
before.gif (72.3 KB) - added by miyauchi 3 years ago.
It's to reproduce this problem, I made mistake after.gif is a movie after fix this problem. :)
keypress.gif (119.4 KB) - added by miyauchi 3 years ago.
Dump keycode for Japanese input

Download all attachments as: .zip

Change History (20)

@miyauchi
3 years ago

#1 @miyauchi
3 years ago

  • Keywords has-patch added

@miyauchi
3 years ago

It's a screencast to reproduce this problem.

@miyauchi
3 years ago

It's to reproduce this problem, I made mistake after.gif is a movie after fix this problem. :)

#2 follow-up: @miyauchi
3 years ago

Sorry, I made a mistake in order to upload files... :)

  • before.gif - It is a gif animation to reproduce this problem.
  • after.gif - It is a gif animation after solved the problem.

Japanese kanji has to be confirmed by enter key.
keyup event will fire then, but keypress or keydown will never been fire when we confirm kanji.

Another place for example theme customizer are using keypress or keydown, so adding tag should use keypress too.

#3 @miyauchi
3 years ago

  • Component changed from Editor to I18N
  • Keywords has-screenshots added
  • Version set to trunk

#4 @nukaga
3 years ago

Hi!
It is the same situation as # 42233. ( @miyauchi also writes.)
Press Enter Key to confirm.
The issue with Japanese input.
Japanese input has a meaning of selection with the Enter key, but when the Enter key press that will decide Add.
I confirmed that #42233 solve with 4.9 Beta3.
I hope the same problem will be solved as well.

This ticket was mentioned in Slack in #core by miyauchi. View the logs.


3 years ago

#6 @swissspidy
3 years ago

@westonruter Since you worked on #42233, would you mind having a look at this one as well?

#7 in reply to: ↑ 2 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 4.9

Replying to miyauchi:

Another place for example theme customizer are using keypress or keydown, so adding tag should use keypress too.

[41873] used keydown, should we be using keydown here as well instead of keypress?

@miyauchi
3 years ago

Dump keycode for Japanese input

#8 @miyauchi
3 years ago

@SergeyBiryukov

I tried them to develop simple app. keypress.gif is a screencast for it.
https://miya0001.github.io/japanese-input/

They are almost same but I guess keypress would be better.
Also, /wp-admin/nav-menus.php is using keypress.

Unfortunately, I tried keypress on [41873] but it wasn't fired, so we are using keydown on [41873].

Thanks :)

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

#9 @SergeyBiryukov
3 years ago

  • Description modified (diff)

#10 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 41988:

Taxonomy: Use keypress instead of keyup for listening for Enter key to add a tag via Tags meta box.

Fixes issue with Japanese input.

Props miyauchi.
Fixes #42234.

#11 @afercia
3 years ago

See discussion starting from https://core.trac.wordpress.org/ticket/38922#comment:37 about how this change broke the previous behavior. There are now 2 keypress on the same input but more importantly there's now the need to press Enter twice to add a term. Previously, one Enter key press was enough because the term was added when releasing the Enter key (on keyup). There's the need of a different solution. Not reopening this ticket because it was closed on a completed milestone.

This ticket was mentioned in Slack in #core-editor by jeffpaul. View the logs.


2 years ago

#13 @miyauchi
21 months ago

@afercia

Gutenberg project is trying to detect Japanese IME with KeyboardEvent.isComposing on following PR.
https://github.com/WordPress/gutenberg/pull/11908

I guess keypress can be changed to keyup if we use KeyboardEvent.isComposing.

This is just a quick note, I hope it will help.

#14 @afercia
21 months ago

@miyauchi very interesting, thank you! Will open a new ticket to follow your suggestion. A fre references:

Browsers support:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing#Browser_compatibility

More details:
https://www.w3.org/TR/uievents/#events-composition-types

Version 0, edited 21 months ago by afercia (next)

#16 @afercia
16 months ago

  • Component changed from I18N to Taxonomy
Note: See TracTickets for help on using tickets.