From 1250795b062c1a2427b515f460f7d9200c8fe333 Mon Sep 17 00:00:00 2001 From: Stas-Buzunko Date: Mon, 17 Feb 2020 20:02:58 +0200 Subject: [PATCH 1/2] add event to onChange --- src/Combobox.jsx | 6 +++--- src/Panel.jsx | 4 ++-- src/Select.jsx | 10 +++++----- src/TimePicker.jsx | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Combobox.jsx b/src/Combobox.jsx index 77dc4119..9f8f5829 100644 --- a/src/Combobox.jsx +++ b/src/Combobox.jsx @@ -19,7 +19,7 @@ const formatOption = (option, disabledOptions) => { }; class Combobox extends Component { - onItemChange = (type, itemValue) => { + onItemChange = (type, itemValue, e) => { const { onChange, defaultOpenValue, @@ -55,11 +55,11 @@ class Combobox extends Component { } } } - onAmPmChange(ampm); + onAmPmChange(ampm, e); } else { value.second(+itemValue); } - onChange(value); + onChange(value, e); }; onEnterSelectPanel = range => { diff --git a/src/Panel.jsx b/src/Panel.jsx index 2444b382..c8335299 100644 --- a/src/Panel.jsx +++ b/src/Panel.jsx @@ -56,10 +56,10 @@ class Panel extends Component { return null; } - onChange = newValue => { + onChange = (newValue, e) => { const { onChange } = this.props; this.setState({ value: newValue }); - onChange(newValue); + onChange(newValue, e); }; onAmPmChange = ampm => { diff --git a/src/Select.jsx b/src/Select.jsx index 2b3e760d..245d60ec 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -41,9 +41,9 @@ class Select extends Component { } } - onSelect = value => { + onSelect = (value, e) => { const { onSelect, type } = this.props; - onSelect(type, value); + onSelect(type, value, e); }; getOptions() { @@ -55,11 +55,11 @@ class Select extends Component { }); const onClick = item.disabled ? undefined - : () => { - this.onSelect(item.value); + : (e) => { + this.onSelect(item.value, e); }; const onKeyDown = e => { - if (e.keyCode === 13) onClick(); + if (e.keyCode === 13) onClick(e); else if (e.keyCode === 27) onEsc(); }; return ( diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 3cb29ed9..13c158b3 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx @@ -72,13 +72,13 @@ class Picker extends Component { : null; } - onPanelChange = value => { - this.setValue(value); + onPanelChange = (value, e) => { + this.setValue(value, e); }; - onAmPmChange = ampm => { + onAmPmChange = (ampm, e) => { const { onAmPmChange } = this.props; - onAmPmChange(ampm); + onAmPmChange(ampm, e); }; onClear = event => { @@ -102,14 +102,14 @@ class Picker extends Component { } }; - setValue(value) { + setValue(value, e) { const { onChange } = this.props; if (!('value' in this.props)) { this.setState({ value, }); } - onChange(value); + onChange(value, e); } getFormat() { From b3feba603ddc3b8260c9925bef0617160e3415a5 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 5 May 2021 15:07:23 +0200 Subject: [PATCH 2/2] Align center --- src/Select.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Select.jsx b/src/Select.jsx index 245d60ec..1b615aa7 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -107,7 +107,7 @@ class Select extends Component { index = 0; } const topOption = this.list.children[index]; - const to = topOption.offsetTop; + const to = topOption.offsetTop + topOption.offsetHeight / 2 - this.root.offsetHeight / 2; // align center scrollTo(this.root, to, duration); }