Skip to content

Commit

Permalink
Update PID row input text whenever item's PID is changed in item pane…
Browse files Browse the repository at this point in the history
… or by fetching

Fixes #292
  • Loading branch information
Dominic-DallOsto committed Sep 17, 2024
1 parent fcc96d9 commit 2b3d666
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/pidRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ function PIDRow(props: {

useEffect(() => {
setUrl(props.item.getPidUrl(props.type));
// update the value of the input to match the new PID
(
document.getElementById(
`pid-row-input-${props.item.key}-${props.type}`,
)! as HTMLInputElement
).value = props.item.getPID(props.type) || "";
}, [props.type, value]);

function handleCommit(newPid: string) {
Expand All @@ -39,12 +45,6 @@ function PIDRow(props: {
await props.item.fetchPID(props.type, props.autosave);
// set new value immediately (see note in handleCommit)
setValue(props.item.getPID(props.type));
// update the value of the input to match the new fetched value
(
document.getElementById(
`pid-row-input-${props.item.key}-${props.type}`,
)! as HTMLInputElement
).value = props.item.getPID(props.type) || "";
}

return (
Expand Down

0 comments on commit 2b3d666

Please sign in to comment.