react-draft-wysiwyg icon indicating copy to clipboard operation
react-draft-wysiwyg copied to clipboard

How do set "name" for the editor?

Open sontek opened this issue 8 years ago • 3 comments

Hey, we put a label on our react-draft-wysiwyg editor. We want that label to focus the editor (<label for="editor" />) like we would in standard HTML for accessibility. How do I do this?

Normally I would do <input name="editor" />

sontek avatar Nov 29 '17 21:11 sontek

Properties passed to the editor are passed down to underlying draft editor check this.

Except for [these])https://github.com/jpuri/react-draft-wysiwyg/blob/master/src/Editor/index.js#L317) props which are filtered out.

Id draftjs supports name wysiwyg will also support it.

jpuri avatar Dec 09 '17 16:12 jpuri

Sorry I dont understand. Can you point out specific how can I pass properties to editor ?

nathannewyen avatar Apr 14 '21 15:04 nathannewyen

As far as I see, it is possible to pass down a wrapperId. I set this to the same as the label's for, but it does not set the focus to the editor, when I click on the label.

One reason why it doesn't work is definitely, that the id of the wrapper is altered to "rdw-wrapper-[yourId]": https://github.com/jpuri/react-draft-wysiwyg/blob/master/src/Editor/index.js#L46

But I'm also not sure if the wrapper is the right element to set the id to. When I have a cursor in the editor, then the active element is <div aria-role="rdw-editor" ... role="textbox" ... > (checked with document.activeElement in the console). So maybe this is the element, the id should be set to, but I'm not sure. I couldn't make it work be altering the ids with Chrome Dev Tools.

dyedwiper avatar Sep 12 '23 10:09 dyedwiper