Feat: use composition event to stabilize korean input

This commit is contained in:
Richard Wong 2024-08-27 17:54:15 +09:00
parent ab75ebbef7
commit faf83b4827
Signed by: richard
GPG Key ID: 72948FBB6D359A6D
1 changed files with 50 additions and 4 deletions

View File

@ -21,6 +21,12 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse
const [verseBool, setVerseBool] = useState(STATE.INCORRECT) const [verseBool, setVerseBool] = useState(STATE.INCORRECT)
const[hintBool, setHintBool] = useState(false) const[hintBool, setHintBool] = useState(false)
const[diffBool, setDiffBool] = useState(false) const[diffBool, setDiffBool] = useState(false)
const [isComposing, setIsComposing] = useState(false);
// Handle the start of composition
const handleCompositionStart = () => {
setIsComposing(true);
};
// function to check correctness of reference input // function to check correctness of reference input
@ -208,7 +214,16 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse
type="text" type="text"
id="referenceBox" id="referenceBox"
name="referenceBox" name="referenceBox"
onChange={referenceChange} onChange={(event) => {
if (!isComposing) {
referenceChange(event);
}
}}
onCompositionStart={handleCompositionStart}
onCompositionEnd={(event) => {
setIsComposing(false);
referenceChange(event);
}}
/> />
</div> </div>
) : ( ) : (
@ -228,7 +243,17 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse
type="text" type="text"
id="chapterTitleBox" id="chapterTitleBox"
name="chapterTitleBox" name="chapterTitleBox"
onChange={chapterTitleChange} onChange={(event) => {
if (!isComposing) {
chapterTitleChange(event);
}
}}
onCompositionStart={handleCompositionStart}
onCompositionEnd={(event) => {
setIsComposing(false);
chapterTitleChange(event);
}}
/> />
</div> </div>
)} )}
@ -242,7 +267,17 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse
type="text" type="text"
id="titleBox" id="titleBox"
name="titleBox" name="titleBox"
onChange={titleChange} onChange={(event) => {
if (!isComposing) {
titleChange(event);
}
}}
onCompositionStart={handleCompositionStart}
onCompositionEnd={(event) => {
setIsComposing(false);
titleChange(event);
}}
/> />
{/* input box for verse */} {/* input box for verse */}
@ -254,7 +289,18 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse
type="text" type="text"
id="verseBox" id="verseBox"
name="verseBox" name="verseBox"
onChange={verseChange} onChange={(event) => {
if (!isComposing) {
verseChange(event);
}
}}
onCompositionStart={handleCompositionStart}
onCompositionEnd={(event) => {
setIsComposing(false);
verseChange(event);
}}
/> />
{/* button to toggle show answer*/} {/* button to toggle show answer*/}