fix(perf): debounce request body textarea Redux dispatch to fix typing#10892
Open
joranv1 wants to merge 1 commit into
Open
fix(perf): debounce request body textarea Redux dispatch to fix typing#10892joranv1 wants to merge 1 commit into
joranv1 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Debounce the Redux dispatch in the request body textarea components to eliminate per-keystroke re-renders.
Both
RequestBodyEditor(OAS3) andParamBody(Swagger 2) were callingprops.onChangewhich dispatches a Redux action and triggers a full component tree re-render on every single keystroke. Since both components already maintain local component state that drives the textarea display, the fix is to keep local state updates immediate (so typing feels instant) while debouncing the Redux dispatch with a 350ms timeout.A
componentWillUnmountcleanup was added to both components to cancel any pending debounce timer on unmount.Motivation and Context
Typing in the request body textarea causes 300–800ms lag per keystroke on medium to large OpenAPI specs, making the Try It Out feature nearly unusable.
This affects both OAS3 (
request-body-editor.jsx) and Swagger 2 (param-body.jsx).The root cause is that every keystroke in the body textarea immediately dispatches a Redux state update, causing the entire component tree to re-render before the next character can be typed. URL/query parameter inputs already avoid this by using
DebounceInputfromreact-debounce-inputwith a 350ms debounce timeout. This fix applies the same pattern to the body textarea components usinglodash/debounce, which is already a project dependency.Fixes #5113
Fixes #5850
How Has This Been Tested?
applyDefaultValue/updateValuespathsdispatch immediately and are not debounced).
npm run test:unit), all pre-existing tests pass, no new failures introduced.npm run build) successfully.Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests