-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DatePicker: fix incorrect interaction on range change when defaultTime provided #9310
DatePicker: fix incorrect interaction on range change when defaultTime provided #9310
Conversation
test/unit/specs/date-picker.spec.js
Outdated
expect(maxDate.getMinutes()).to.be.equal(0); | ||
expect(maxDate.getSeconds()).to.be.equal(0); | ||
done(); | ||
expect(rightCell.className.split(' ').indexOf('in-range') >= 0).to.be.true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using classList
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the browser support requirement of element. But it is safer to use className
and almost the same complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are executed in Chrome. so I don't think this will be an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe possible future e2e tests in different browsers? If browser supporting has never become an issue when writing test cases in this project, I'll use classList.contains
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can safely use classList. 2.0 requires ie >10 which supports it. see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great.
const defaultTime = this.defaultTime || []; | ||
this.minDate = modifyWithGivenTime(val.minDate, defaultTime[0]); | ||
this.maxDate = modifyWithGivenTime(val.maxDate, defaultTime[1]); | ||
this.minDate = val.minDate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to "trim" time before passing {min, max}Date
to date-table
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cancelled my previous changes here to fix this issue (now it's just the same behavior as what it used to be). If we want to add trim
behavior before passing minDate
/ maxDate
to date-table
, maybe that should be another issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I mean resetting the time to 00:00:00 before passing minDate/maxDate to date-table.
date-table checks date equality in a naive way, so it can not handle non 00:00:00 time. But the rest of date-range panel should know about the selected time.
Like this:
<date-table :min-date="resetTime(minDate)">
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Thx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it is a little complex to realize this.
-
I have to reset to
12:00:00
to make it work (I'm still looking into why), which will change the default behavior on pick. -
There is some "reference equal" issue, which means, when
resetTime
returns a newDate
object (even with the same time value), it breaks.
I'll spend time on it later. If you have any ideas about the above problems, plz hint me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Might have something to do with legacy codes. I suggest you keep current solution, it works. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that.
481a62e
to
b3ad2a6
Compare
IE11 下 dafaulttime 根本无效,麻烦好好测试一下,只支持chrome的组件真的没什么卵用 |
Fix interaction issue introduced in #9094 (comment)
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.