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

Reselect element with focus when datepicker closes #3317

Closed
peterblazejewicz opened this issue Jul 28, 2019 · 3 comments · Fixed by #3371
Closed

Reselect element with focus when datepicker closes #3317

peterblazejewicz opened this issue Jul 28, 2019 · 3 comments · Fixed by #3371

Comments

@peterblazejewicz
Copy link
Contributor

This is request for change.

When:

This would allow users to quickly reselect value in the case of e.g. minor error that could be quickly corrected
.
Other reference implementation supporting this behaviour:
https://material.angular.io/components/datepicker/overview
https://clarity.design/documentation/datepicker#examples

This would be non breaking change (unless some tests rely on keyboard navigation with presumed current focus behaviour).

Thanks!

NgBootstrap: 5.1

@maxokorokov maxokorokov modified the milestones: 5.1.2, 5.2.0 Sep 20, 2019
maxokorokov added a commit to maxokorokov/ng-bootstrap that referenced this issue Sep 20, 2019
At the moment the focus is lost, so it will be restored to the
previously focused element (before datepicker was opened)

Fixes ng-bootstrap#3317
Fixes ng-bootstrap#3358
@maxokorokov maxokorokov modified the milestones: 5.2.0, 5.1.2 Sep 20, 2019
maxokorokov added a commit to maxokorokov/ng-bootstrap that referenced this issue Sep 20, 2019
At the moment the focus is lost, so it will be restored to the
previously focused element (before datepicker was opened)

Fixes ng-bootstrap#3317
Fixes ng-bootstrap#3358
maxokorokov added a commit that referenced this issue Sep 26, 2019
At the moment the focus is lost, so it will be restored to the
previously focused element (before datepicker was opened)

Fixes #3317
@chumbalum
Copy link

Hi. This change breaks the usage of opening the datepicker via

<input (focus)="Datepicker.open()"/>

When the datepicker is dismissed by clicking somewhere else, the input gets focussed again and reopens the datepicker, therefore it will never close again.

@maxokorokov unless there is another way of opening the datepicker on focus, this seems to be a bug for me

@terencehonles
Copy link
Contributor

Hi. This change breaks the usage of opening the datepicker via

<input (focus)="Datepicker.open()"/>

When the datepicker is dismissed by clicking somewhere else, the input gets focussed again and reopens the datepicker, therefore it will never close again.

@maxokorokov unless there is another way of opening the datepicker on focus, this seems to be a bug for me

We also stumbled across this bug

@terencehonles
Copy link
Contributor

terencehonles commented Nov 21, 2019

Thinking about this more I think this functionality should either be explicitly enabled:

<input ngbDatepicker [refocus]="true" />

Or focus should be manually set by the user:

<input ngbDatepicker (closed)="otherElement.focus()" />

There doesn't seem to be any way for this to play nicely with (focus)="picker.open()" which @chumbalum and @zm3d3ni (directly on the commit and copied below) mention they also are running into.

@maxokorokov why you want to refocus? We are using focus to open datepicker (https://stackblitz.com/edit/angular-phaczz) and you cannot close it anymore if you click outside datepicker.

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

Successfully merging a pull request may close this issue.

5 participants