Skip to content
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

Merged
merged 1 commit into from
Jan 18, 2018

Conversation

nighca
Copy link
Contributor

@nighca nighca commented Jan 17, 2018

Fix interaction issue introduced in #9094 (comment)

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow Element's contributing guide (中文 | English | Español).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using classList ?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

@nighca nighca Jan 17, 2018

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;
Copy link
Contributor

@wacky6 wacky6 Jan 17, 2018

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@wacky6 wacky6 Jan 17, 2018

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)">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Thx.

Copy link
Contributor Author

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.

  1. 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.

  2. There is some "reference equal" issue, which means, when resetTime returns a new Date 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.

Copy link
Contributor

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. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that.

@nighca nighca force-pushed the debug-date-picker-default-time branch from 481a62e to b3ad2a6 Compare January 17, 2018 10:46
@Leopoldthecoder Leopoldthecoder merged commit 2880132 into ElemeFE:dev Jan 18, 2018
@liwenda122
Copy link

IE11 下 dafaulttime 根本无效,麻烦好好测试一下,只支持chrome的组件真的没什么卵用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants