Skip to content

Commit 3552bca

Browse files
committed
fix onNext/onFinish semantics
1 parent 14606c0 commit 3552bca

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-nlp-annotate",
3-
"version": "0.3.7",
3+
"version": "0.3.10",
44
"homepage": "https://universaldatatool.github.io/react-nlp-annotate/",
55
"main": "./dist/lib.js",
66
"dependencies": {

src/components/NLPAnnotator/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ export default function NLPAnnotator(props: NLPAnnotatorProps) {
4040
if (!props.hotkeysEnabled) return
4141
const eventFunc = e => {
4242
if (e.key === "Enter") {
43-
if (props.onFinish) props.onFinish(output)
43+
if (props.onNext) {
44+
props.onNext(output)
45+
} else if (props.onFinish) {
46+
props.onFinish(output)
47+
}
4448
}
4549
}
4650
window.addEventListener("keydown", eventFunc)
@@ -66,6 +70,8 @@ export default function NLPAnnotator(props: NLPAnnotatorProps) {
6670
msg.toLowerCase().includes("error")
6771
)
6872

73+
const onNext = useEventCallback(() => props.onNext(output))
74+
const onPrev = useEventCallback(() => props.onPrev(output))
6975
const onFinish = useEventCallback(() => {
7076
if (!isPassingValidation) return
7177
props.onFinish(output)
@@ -74,6 +80,7 @@ export default function NLPAnnotator(props: NLPAnnotatorProps) {
7480
const onClickHeaderItem = useEventCallback(({ name }) => {
7581
switch (name) {
7682
case "Done":
83+
case "Save":
7784
onFinish(output)
7885
return
7986
default:
@@ -113,8 +120,8 @@ export default function NLPAnnotator(props: NLPAnnotatorProps) {
113120
return (
114121
<Container
115122
titleContent={props.titleContent}
116-
onNext={props.onNext}
117-
onPrev={props.onPrev}
123+
onNext={props.onNext ? onNext : null}
124+
onPrev={props.onPrev ? onPrev : null}
118125
onClickHeaderItem={onClickHeaderItem}
119126
>
120127
<div>{annotator}</div>

0 commit comments

Comments
 (0)