Skip to content

fix(rn): prevent duplicate radio/checkbox change events - #2546

Open
yandadaFreedom wants to merge 12 commits into
masterfrom
fix-radio-change-event
Open

fix(rn): prevent duplicate radio/checkbox change events#2546
yandadaFreedom wants to merge 12 commits into
masterfrom
fix-radio-change-event

Conversation

@yandadaFreedom

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread packages/webpack-plugin/lib/runtime/components/react/getInnerListeners.ts Outdated

const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
markLabelControlHandled(evt)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markLabelControlHandled(evt) 建议放到业务 bindtap 之前。RN 的事件分发会用 guarded callback 隔离单个 listener 的异常;如果 bindtap 同步抛错,当前函数会在写入标记前退出,但原始事件仍可能继续冒泡到 label,导致 label 再执行 triggerChange,出现异常路径下状态仍被切换的情况。建议顺序调整为 markLabelControlHandled(evt)bindtap(...)onChange(evt)mpx-checkbox.tsx 中的同处逻辑也请同步调整。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants