Skip to content

Commit

Permalink
Allow using TextInput outside forms
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Feb 21, 2024
1 parent e1905e3 commit 10e116d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/widgets/TextInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class TextInput extends React.Component {
onChange = (ev) => {
const curValue = ev.target.innerHTML.replace(/<br\s*\/?>$/, '');
this.setState({curValue: curValue, changed: true});
if (this.formEl.form) {
if (this.formEl?.form) {
// Notify parent form picks of changed field
// https://stackoverflow.com/a/46012210
const nativeSet = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
Expand Down Expand Up @@ -199,7 +199,7 @@ class TextInput extends React.Component {
if (this.state.changed) {
const valueWithLinks = MiscUtils.addLinkAnchors(this.state.curValue);
this.props.onChange(valueWithLinks);
if (this.formEl.form) {
if (this.formEl?.form) {
// Notify parent form picks of changed field
// https://stackoverflow.com/a/46012210
const nativeSet = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
Expand Down

0 comments on commit 10e116d

Please sign in to comment.