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.

RichText not updating properly based on state

See original GitHub issue

Category

[ ] Enhancement

[X] Bug

[ ] Question

Version

Please specify what version of the library you are using: [1.20.0]

Expected / Desired Behavior / Question

I expect the text to update properly whenever the onChange handler is called. Also, why do you need it to return a string, instead of just accepting the updated state as a prop?

Observed Behavior

The webpart is only updating the first keystroke. All subsequent strokes seems to be disregarded, and will not be recorded unless I click outside the webpart and then refocus by clicking inside.

Steps to Reproduce

Please try the following code snippet:

import * as React from "react";
import { RichText } from "@pnp/spfx-controls-react/lib/RichText";

const RichTextExample: React.FC = (props) => {
  const [text, setText] = React.useState("Default text");

  const onChange = (newText: string) => {
    setText(newText); 
    return newText;
  };

  return <RichText value={text} onChange={onChange} />;
};

export default RichTextExample;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
AJIXuMuKcommented, Dec 13, 2020

Hi all,

I’ve made the fix. Please, check beta version.

@nbelyh @Abderahman88 @vaderj @michelsmit @nwinger

1reaction
Abderahman88commented, Nov 29, 2020

@nbelyh The controlled mode is not working. (Tested with your example)

This needs to be fixed 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter setState not updating RichText widget - Stack Overflow
The widget is not updating because you're not changing the actual List object but just adding more items to the existing List object....
Read more >
Enable or disable full rich-text formatting in a rich text box
If you enable rich-text formatting for a rich text box, users can use a variety of options to format the text that they...
Read more >
Bug: Rich Text Editor HTML state not updated - Zeroqode Forum
Hi, I'm using the ZQ RTE plugin. When I set the initial content or when I use the action to set content. i.e....
Read more >
Not able to update Rich text field with XML data
Yes it is working fine now... I have just changed the field type from Rich Text to Text Area(Long)..
Read more >
lightning-input-rich-text - documentation - Salesforce Developers
A lightning-input-rich-text component creates a rich text editor based on the ... using the missing formats are not rendered correctly in the text...
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