From bc52b2db912d6714f5cb2145532fcb6835d084c7 Mon Sep 17 00:00:00 2001 From: liuzedong02 Date: Mon, 21 Feb 2022 19:16:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=84=E5=88=86=20=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?&=E5=8A=A8=E4=BD=9C=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Form/InputRating.tsx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/renderers/Form/InputRating.tsx b/src/renderers/Form/InputRating.tsx index a15a598ef..a0c764aca 100644 --- a/src/renderers/Form/InputRating.tsx +++ b/src/renderers/Form/InputRating.tsx @@ -93,25 +93,19 @@ export default class RatingControl extends React.Component { } } - async dispatchChangeEvent(eventName: string, eventData: any = {}) { - const {dispatchEvent, data} = this.props; - const rendererEvent = await dispatchEvent( - eventName, - createObject(data, { - value: eventData, - }) - ); - - return rendererEvent?.prevented ?? false; - } - @autobind async handleChange(value: any) { - const {onChange} = this.props; + const {onChange, dispatchEvent, data} = this.props; - const prevented = await this.dispatchChangeEvent('change', value); + const rendererEvent = await dispatchEvent('change', createObject(data, { + value + })); - prevented || (onChange && onChange(value)); + if (rendererEvent?.prevented) { + return; + } + + onChange && onChange(value); } render() {