Skip to content

Commit

Permalink
fix: datePicker focus and blur are executed at the same time vueCompo…
Browse files Browse the repository at this point in the history
  • Loading branch information
刘春春 committed Feb 27, 2024
1 parent 7c1a14b commit fd5b201
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/date-picker/createPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export default function createPicker(TheCalendar, props) {
inputReadOnly,
},
on: {
handleFocus: focus,
handleBlur: blur,
ok,
panelChange,
change: this.handleCalendarChange,
Expand Down Expand Up @@ -225,8 +227,6 @@ export default function createPicker(TheCalendar, props) {
<input
ref="input"
disabled={props.disabled}
onFocus={focus}
onBlur={blur}
readOnly
value={formatDate(inputValue, this.format)}
placeholder={placeholder}
Expand Down
2 changes: 2 additions & 0 deletions components/vc-calendar/src/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ const Calendar = {
onSelect={this.onDateInputSelect}
inputMode={inputMode}
inputReadOnly={inputReadOnly}
onFocus={() => this.__emit('handleFocus')}
onBlur={() => this.__emit('handleBlur')}
/>
) : null;
const children = [];
Expand Down
2 changes: 2 additions & 0 deletions components/vc-calendar/src/date/DateInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ const DateInput = {
},
onFocus() {
this.setState({ hasFocus: true });
this.__emit('focus');
},
onBlur() {
this.setState((prevState, prevProps) => ({
hasFocus: false,
str: formatDate(prevProps.value, prevProps.format),
}));
this.__emit('blur');
},
onKeyDown(event) {
const { keyCode } = event;
Expand Down

0 comments on commit fd5b201

Please sign in to comment.