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: closing datepicker focuses input, breaking "open with focus" #7638

Open
fxck opened this issue Oct 8, 2017 · 3 comments
Open
Labels
area: docs Related to the documentation area: material/datepicker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@fxck
Copy link
Contributor

fxck commented Oct 8, 2017

https://stackblitz.com/edit/angular-material2-issue-b9oh8q?file=app%2Fapp.component.ts

  1. focus input
  2. select something, datepicker closes
  3. (input focused) hit backspace couple of times
  4. blur input
  5. try to correct now nonsensical date
  6. you are screwed, because input it not focused

it wasn't happening pre-beta.12, I would like to be able to turn this autofocus on close off again

cc @mmalerba @crisbeto

@mmalerba
Copy link
Contributor

mmalerba commented Oct 9, 2017

I think returning focus to where it started is the behavior most people will want. You should be able to get it to do something else by either blurring the active element or focusing the element you want focus to return to right before opening the datepicker. For example:

(focus)="$event.target.blur(); dp.open()"

@fxck
Copy link
Contributor Author

fxck commented Oct 9, 2017

..or we could add disableFocusRestore, it's three lines of code, I know you don't want to keep adding APIs, but I think this one is legit and has use cases

@mmalerba
Copy link
Contributor

mmalerba commented Oct 9, 2017

I'd prefer not to add a new API since it can be easily accomplished without it. I could see adding a note to the docs about it, which I can do when I get to updating the datepicker docs (next on my list after I finish input & select which I'm currently working on)

@mmalerba mmalerba added docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Nov 21, 2017
@mmalerba mmalerba added area: docs Related to the documentation and removed docs This issue is related to documentation labels Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs Related to the documentation area: material/datepicker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
3 participants