pnp / pnp/sp-dev-fx-controls-react
Rich text crashes when clicked multiple times in a row
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 433
- Forks
- 418
- Avg merge
- 5d 6m
- Merged PRs (30d)
- 19
Description
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:
https://github.com/pnp/sp-dev-fx-controls-react/blob/2f2839739fbd6337fa171cab88afc67e1b434f53/src/controls/richText/RichText.tsx#L854-L873
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/controls/richText/RichText.tsx around lines 854-873, especially the setState call associated with clicking the control. Reproduce the problem by rapidly clicking formatted RichText content, such as a hyperlink, several times. Done means repeated clicks no longer cause React's maximum update depth crash and the control remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100