Rich Text focus disapppear
See original GitHub issueThank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your needs please complete the below template to ensure we have the details to help. Thanks!
Please check out the documentation to see if your question is already addressed there. This will help us ensure our documentation is up to date.
Category
[ ] Enhancement
[x] Bug
[ ] Question
Version
1.13.0-beta.892b624
Expected / Desired Behavior / Question
focus not disappear
Observed Behavior
focus disappear after enter one symbol
Steps to Reproduce
basic setState usage
import * as React from 'react';
import { IHelloWorldProps } from './IHelloWorldProps';
import { RichText } from "@pnp/spfx-controls-react/lib/RichText";
export default class HelloWorld extends React.Component<IHelloWorldProps, { value: string }> {
constructor(props: IHelloWorldProps) {
super(props);
this.state = {
value: ''
};
}
private onChange = (value: string) => {
this.setState({ value });
return value;
}
public render(): React.ReactElement<IHelloWorldProps> {
return (
<div><RichText value={this.state.value} onChange={(text) => this.onChange(text)} /></div>
);
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Javascript rich text editor, contenteditable area loses focus ...
Well the focus moves to the button so you need to cancel the click action so the focus is not lost in the...
Read more >Rich Text Editor: leaving focus does not kill onsc...
Rich Text Editor: leaving focus does not kill onscreen phone keyboard ... some text; I tap on the icon, but the keyboard DOESN'T...
Read more >DynamicForm RichText Field losing focus on typing #1024
Using the DynamicForm component with a RichText field should not lose focus when typing in the rich text field.
Read more >Trigger Save when Rich Text Editor loses focus or before the ...
I would like to use the Rich Text Editor with no save button. ... and then navigate away or close the browser and...
Read more >RadRichTextBox gets focus but does not display cursor and ...
Hi Andrew, We have logged an issue that the caret inside the document disappears but the focus remains in the control and users...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As you are storing the value back to the state of your web part, it will re-render the HTML. That is why you lose focus. You can also store the value as a private variable in your component. That will not trigger a re-render.
Thanks for the answers guys,
@kirillstarlight Your method worked for me. I duplicated the value in the constructor and used that as the value for the control and updated the state of the parent with
onChange
. This however feels fairly dirty and I’d much rather prefer some form of.focus()
accessor for the control or have it support statefull components 😕(I tried getting the quill editor via reference and focusing that but it didn’t work) i.e.