question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addon-controls text input cannot handle Japanese (most likely all CJK text)

See original GitHub issue

Describe the bug addon-controls’ text-input doesn’t handle Japanese typing events. Most likely caused by listening to oninput instead of onchange. Pasted Japanese text displays normally.

To Reproduce

  1. Create a control that has a text input
  2. Try typing Japanese directly into input (ex. 編集)
  3. See garbled string

Expected behavior Input contains string “編集”. Copying and pasting this string will display expected result. Actually typing the text into the input causes the error.

Screenshots https://www.loom.com/share/5310ef1bd23e4f07b9c93ee528d0c948

System:

Environment Info:

  System:
    OS: macOS 10.15.5
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
  Binaries:
    Node: 14.3.0 - /var/folders/q6/mtqdcmhs7nl4zxxpdf0tr_xm0000gn/T/fnm-shell-1945621/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.5 - /var/folders/q6/mtqdcmhs7nl4zxxpdf0tr_xm0000gn/T/fnm-shell-1945621/bin/npm
  Browsers:
    Chrome: 83.0.4103.116
    Safari: 13.1.1
  npmPackages:
    @storybook/addon-controls: ^6.0.0-beta.37 => 6.0.0-beta.37
    @storybook/addon-docs: ^6.0.0-beta.37 => 6.0.0-beta.37
    @storybook/angular: ^6.0.0-beta.37 => 6.0.0-beta.37

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ndelangencommented, Jun 30, 2020
  • If we make it an uncontrolled input, the characters combine properly
  • the event send TO the preview already contains the incorrect string
  • if we start using the value from useState the issue starts
1reaction
shilmancommented, Jun 29, 2020

@brandonpittman i’ve lived in japan, korea, and currently in taiwan so i’m a bit embarrassed about this one. hopefully we can fix it soon, tho it turns out that it’s not as easy as i’d hoped to track down.

both controls (new, broken code) and knobs (old, working code) effectively have the same logic:

export const TextControl: FC<TextProps> = ({ name, value, onChange }) => {
  const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
    onChange(name, event.target.value);
  };
  return <Form.Textarea id={name} name={name} value={value} onChange={handleChange} size="flex" />;
};

in both cases, it is a “controlled component” where the value is passed in and the onChange hooks into an external state management system. there’s something different about the value that’s getting passed in and i’m wondering if you know enough about CJK to help me debug.

i was using korean ㅁㅏㄴ vs 만. is there a version of the string “ㅁ” that is "open to adding more characters to, and a version of the string “ㅁ” that is “end of character”? if so, how would i programmatically convert from the former to the latter? my hypothesis is that the args state management system is unintentionally making that conversion, whereas the knobs state management is not. since they are using the exact same Form.Textarea component.

UPDATE: I replaced the knobs component with a nearly identical copy of the controls component and have confirmed it’s an issue in the state management side cc @ndelangen @tmeasday

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text Editing Hates You Too - Hacker News
For decades I've been saying that all text input should go through OS-level IMEs (input method editors). For more complex scripts, the need...
Read more >
[APP] Japanese display and input addon (updated 2009.07.03 ...
What this does is that it enables display and input of Japanese characters. It can for instance be used to read web pages,...
Read more >
CJK(Chinese, Japanese, Korean): extra space is inserted ...
CJK (Chinese, Japanese, Korean): extra space is inserted within text in mail due to wrap produced by mailnews.wraplength and line length limitation of...
Read more >
Controls - Storybook - JS.ORG
To use the Controls addon, you need to write your stories using args. ... By default, Storybook will render a free text input...
Read more >
How to Set Up the MorphMan Anki Add-On
For all other languages you'll probably want to use “Language w/ Spaces”. “CJK characters” will also work for text with Chinese characters but ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found