Skip to content

Rich text crashes when clicked multiple times in a row #1103

Open
@nbelyh

Description

@nbelyh

Category

[ ] Enhancement
[x] Bug
[ ] Question

Version

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

Expected / Desired Behavior / Question

Nothing happens.

Observed Behavior

The application crashes (react crashes), with message:

Uncaught Invariant Violation: Maximum update depth exceeded. 
This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. 
React limits the number of nested updates to prevent infinite loops.

Crashes here, at the row 867, this.setState:

private handleChangeSelection = (range, oldRange, source) => {
const quill = this.getEditor();
try {
if (quill) {
// Get the selected text
const selectedText = quill.getText(range);
// Get the current format
const formats = quill.getFormat(range);
// Get the currently selected url
const selectedUrl = formats.link ? formats.link : undefined;
this.setState({
selectedText: selectedText,
selectedUrl: selectedUrl,
formats: formats
});
if (this._propertyPaneRef && this.state.morePaneVisible) {

Steps to Reproduce

Quickly (milliseconds) click in the RichText text control several times, like five or so (using left mouse button).
The rich text should not be empty (should contain some formatted text, such as a hyperlink)

It looks like the handler just enters the infinite loop, maybe a safeguard around it could solve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions