Skip to content

Commit

Permalink
Fix: Update TextInputTab to pass inputIndex to textChanged function, … (
Browse files Browse the repository at this point in the history
#37)

* Fix: Update TextInputTab to pass inputIndex to textChanged function, fixing URL overwirte with text inputs

* Fix issue of error being consoled even for single inputs
  • Loading branch information
ShivanshShalabh authored Jul 29, 2024
1 parent a947882 commit 78ed6ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function TextInputTab(props) {
<textarea
value={text}
className={getElement("input")}
onChange={(e) => textChanged(e)}
onChange={(e) => textChanged(e, props?.inputIndex)}
></textarea>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import {useState} from "react";
import { useState } from "react";
import Task from "../../../../../helpers/Task";

export default function useTextInputControl(props) {
const [text, setText] = useState(props.values[0]);
const task = Task.getStaticTask(props.task);

const textChanged = async (event) => {
const textChanged = async (event, index = null) => {
if (event.persist) {
event.persist();
}

setText(event.target.value);

if (typeof(props.inputSelected) === "function") {
props.inputSelected(text, 0);
if (typeof (props.inputSelected) === "function") {
if (index !== null) {
props.inputSelected(text, index);
}
}
}
};

return {
task,
text,
textChanged
}
};
}

0 comments on commit 78ed6ae

Please sign in to comment.