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] Add ability to use keyboard to write date #5677

Closed
wants to merge 5 commits into from

Conversation

aralot
Copy link

@aralot aralot commented Nov 28, 2016

As for now you can only use mouse clicks to change the date in DatePicker. I've added the ability to use keyboard.

Use keyboardEnabled prop to enable keyboard input for DatePicker.

Unfortunately by now it is only working with default locale (en-US). In other cases keyboardEnabled prop will be ignored. Also it will not work if it is controlled component or has disabled dates.

Fix mui/mui-x#6232

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

@muibot muibot added PR: Needs Review PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI and removed PR: Needs Review labels Nov 28, 2016
@caesay
Copy link

caesay commented Dec 2, 2016

My pull request for this issue #5030 has been open since August

@oliviertassinari oliviertassinari added the component: date picker This is the name of the generic UI component, not the React module! label Dec 3, 2016
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Thanks for this PR.
The demo is quite cool.
However, I'm not sure we gonna move forward with this PR, we want to focus on bug fixes for the master branch and the migration of components on the next branch.

import IconButton from '../IconButton';
import DateRangeIcon from '../svg-icons/action/date-range';

export function getStyles() {
Copy link
Member

Choose a reason for hiding this comment

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

Why exporting this function?

shouldHandleKeyboard() {
return this.props.keyboardEnabled && !this.props.disabled &&
!this.props.locale && !this.props.shouldDisableDate &&
!this.isControlled();
Copy link
Member

Choose a reason for hiding this comment

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

I'm worried about this feature being disabled for controlled component.
On the next branch, we only focus on stateless component, hence, they are all controlled at their lowest implementation level.
What's the issue?

ref="input"
style={textFieldStyle}
value={this.state.date ? formatDate(this.state.date) : ''}
errorText={this.state.hasError && errorText}
Copy link
Member

Choose a reason for hiding this comment

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

That's a breaking change as users might be using this errorText property independently from the hasError state. I would rather move that error logic away into another state error wrapper component.

onFocus={this.handleFocus}
onTouchTap={this.handleTouchTap}
onTouchTap={!this.shouldHandleKeyboard() && this.handleTouchTap}
Copy link
Member

Choose a reason for hiding this comment

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

Same, that's a breaking change.


return (
<div className={className} style={prepareStyles(Object.assign({}, style))}>
<TextField
{...other}
onBlur={this.handleBlur}
onChange={this.handleTextChange}
Copy link
Member

Choose a reason for hiding this comment

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

Same, that's a breaking change.


return (
<div className={className} style={prepareStyles(Object.assign({}, style))}>
<TextField
{...other}
onBlur={this.handleBlur}
Copy link
Member

Choose a reason for hiding this comment

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

Same, that's a breaking change.

@@ -253,6 +320,21 @@ class DatePicker extends Component {
}
};

parseDate = (textDate) => {
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to allow users using a different date format.
Like DD-MM-YYYY.

@@ -150,11 +177,15 @@ class DatePicker extends Component {

state = {
date: undefined,
hasError: false,
textDate: '',
Copy link
Member

Choose a reason for hiding this comment

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

What's the use case for this new state?

@oliviertassinari
Copy link
Member

I'm closing this PR as has been inactive for quite some time. Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: date picker This is the name of the generic UI component, not the React module! PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DatePicker] Use keyboard to write date
4 participants