Skip to content

fix: Add debounce to textarea component to improve performance #10345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/components/layout-utils.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import PropTypes from "prop-types"
import DebounceInput from "react-debounce-input"

function xclass(...args) {
return args.filter(a => !!a).join(" ").trim()
Expand Down Expand Up @@ -124,8 +125,7 @@ export class Button extends React.Component {

}


export const TextArea = (props) => <textarea {...props} />
export const TextArea = (props) => <DebounceInput element="textarea" debounceTimeout={350} forceNotifyByEnter={false} {...props} />

export const Input = (props) => <input {...props} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe("OpenAPI 3.0 Validation for Required Request Body and Request Body Fiel
)
.should("not.have.class", "invalid")
.clear()
.blur() // HACK: force the debounce on the textarea to trigger
// Execute
.get(".execute.opblock-control__btn")
.click()
Expand All @@ -104,6 +105,7 @@ describe("OpenAPI 3.0 Validation for Required Request Body and Request Body Fiel
)
.clear()
.type(" ")
.blur() // HACK: force the debounce on the textarea to trigger
// Execute
.get(".execute.opblock-control__btn")
.click()
Expand Down Expand Up @@ -197,6 +199,7 @@ describe("OpenAPI 3.0 Validation for Required Request Body and Request Body Fiel
)
.should("not.have.class", "invalid")
.clear()
.blur() // HACK: force the debounce on the textarea to trigger
// Execute
.get(".execute.opblock-control__btn")
.click()
Expand Down