Skip to content

Commit

Permalink
fix: disabled button tap can callback
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhomie committed Aug 29, 2024
1 parent d9e6199 commit 54b29ea
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
3 changes: 2 additions & 1 deletion compiled/alipay/demo/pages/Stepper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Page({
handleMinusValue() {
this.setData({ value: this.data.value - 1 });
},
handleDisabledTap() {
handleDisabledTap(e) {
console.log('禁用点击:', e.target.dataset);
my.showToast({ content: '禁用点击' });
},
});
10 changes: 3 additions & 7 deletions compiled/alipay/src/Stepper/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Component,
triggerEvent,
getValueFromProps,
triggerEventOnly,
} from '../_util/simply';
import { Component, triggerEvent, getValueFromProps } from '../_util/simply';
import { StepperDefaultProps } from './props';
import { getPrecision, getValidNumber } from './utils';
import mixinValue from '../mixins/value';
Expand Down Expand Up @@ -34,7 +29,8 @@ Component(
triggerEvent(this, 'blur', value === '' ? null : Number(value), e);
},
onDisabledTap(e) {
triggerEventOnly(this, 'disabledTap', e);
const onDisabledTap = getValueFromProps(this, 'onDisabledTap');
onDisabledTap && onDisabledTap(e);
},
onTap(e) {
const [
Expand Down
3 changes: 2 additions & 1 deletion compiled/wechat/demo/pages/Stepper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Page({
handleMinusValue() {
this.setData({ value: this.data.value - 1 });
},
handleDisabledTap() {
handleDisabledTap(e) {
console.log('禁用点击:', e.target.dataset);
my.showToast({ content: '禁用点击' });
},
});
5 changes: 3 additions & 2 deletions compiled/wechat/src/Stepper/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, triggerEvent, getValueFromProps, triggerEventOnly, } from '../_util/simply';
import { Component, triggerEvent, getValueFromProps, } from '../_util/simply';
import { StepperDefaultProps } from './props';
import { getPrecision, getValidNumber } from './utils';
import mixinValue from '../mixins/value';
Expand All @@ -25,7 +25,8 @@ Component(StepperDefaultProps, {
triggerEvent(this, 'blur', value === '' ? null : Number(value), e);
},
onDisabledTap: function (e) {
triggerEventOnly(this, 'disabledTap', e);
var onDisabledTap = getValueFromProps(this, 'onDisabledTap');
onDisabledTap && onDisabledTap(e);
},
onTap: function (e) {
var _a = getValueFromProps(this, [
Expand Down
3 changes: 2 additions & 1 deletion demo/pages/Stepper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Page({
handleMinusValue() {
this.setData({ value: this.data.value - 1 });
},
handleDisabledTap() {
handleDisabledTap(e) {
console.log('禁用点击:', e.target.dataset);
my.showToast({ content: '禁用点击' });
},
});
10 changes: 3 additions & 7 deletions src/Stepper/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Component,
triggerEvent,
getValueFromProps,
triggerEventOnly,
} from '../_util/simply';
import { Component, triggerEvent, getValueFromProps } from '../_util/simply';
import { StepperDefaultProps } from './props';
import { getPrecision, getValidNumber } from './utils';
import mixinValue from '../mixins/value';
Expand Down Expand Up @@ -34,7 +29,8 @@ Component(
triggerEvent(this, 'blur', value === '' ? null : Number(value), e);
},
onDisabledTap(e) {
triggerEventOnly(this, 'disabledTap', e);
const onDisabledTap = getValueFromProps(this, 'onDisabledTap');
onDisabledTap && onDisabledTap(e);
},
onTap(e) {
const [
Expand Down

0 comments on commit 54b29ea

Please sign in to comment.