fix(mini): preserve child name input during pinyin composition
This commit is contained in:
@@ -20,7 +20,6 @@ import {
|
||||
CHILD_NAME_RULE_MESSAGE,
|
||||
createChild,
|
||||
getChildren,
|
||||
sanitizeChildNameInput,
|
||||
resolveChildSelection,
|
||||
setSelectedChildId as setStoredSelectedChildId,
|
||||
validateChildNameInput,
|
||||
@@ -804,9 +803,10 @@ export default function Bind() {
|
||||
? children.length > 0 ? '不选已有宝贝时,可填写2-5位简体中文姓名(暂不支持数字和英文)' : CHILD_NAME_RULE_MESSAGE
|
||||
: children.length > 0 ? '不选已有宝贝时,可填写2-5位简体中文姓名(暂不支持数字和英文)' : '可不填,稍后再关联宝贝'
|
||||
}
|
||||
maxlength={5}
|
||||
maxlength={-1}
|
||||
onInput={(event) => {
|
||||
const nextChildName = sanitizeChildNameInput(event.detail.value)
|
||||
// Preserve pinyin composition; validate the final name on submit.
|
||||
const nextChildName = event.detail.value
|
||||
setNewChildName(nextChildName)
|
||||
if (nextChildName) {
|
||||
setSelectedChildId(null)
|
||||
|
||||
@@ -26,7 +26,6 @@ import {
|
||||
CHILD_NAME_RULE_MESSAGE,
|
||||
clearSelectedChildId,
|
||||
deleteChild,
|
||||
sanitizeChildNameInput,
|
||||
setSelectedChildId,
|
||||
updateChild,
|
||||
validateChildNameInput,
|
||||
@@ -1496,8 +1495,8 @@ export default function Sleep() {
|
||||
value={childName}
|
||||
placeholder={CHILD_NAME_RULE_MESSAGE}
|
||||
focus
|
||||
maxlength={5}
|
||||
onInput={(event) => setChildName(sanitizeChildNameInput(event.detail.value))}
|
||||
maxlength={-1}
|
||||
onInput={(event) => setChildName(event.detail.value)}
|
||||
/>
|
||||
</View>
|
||||
<View className='modal-actions'>
|
||||
|
||||
@@ -17,10 +17,6 @@ export function normalizeChildNameInput(value?: string | null): string {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
export function sanitizeChildNameInput(value?: string | null): string {
|
||||
return normalizeChildNameInput(value).replace(/[^\u4e00-\u9fa5]/g, '').slice(0, 5)
|
||||
}
|
||||
|
||||
export function validateChildNameInput(value?: string | null): string {
|
||||
const childName = normalizeChildNameInput(value)
|
||||
if (!childName) return '请输入宝贝姓名'
|
||||
|
||||
Reference in New Issue
Block a user