primeng icon indicating copy to clipboard operation
primeng copied to clipboard

DatePicker require double click in IE11 to select date

Open dkirolos opened this issue 9 years ago • 4 comments

http://plnkr.co/edit/HPqPaFGNvlDEnOykgGBT?p=preview

Current behavior Date picker require double click in IE11 to select date from date picker

Expected behavior Date picker require only once click in IE11 to select date from date picker

  • Angular version: 2.3.1

  • PrimeNG version: 2.0.0

  • Browser: IE 11

  • Language: TypeScript 2.0.3

  • Node (for AoT issues): node --version = 4.4.3

  • ** Windows 7

dkirolos avatar Feb 10 '17 02:02 dkirolos

This is the same issue as #2026 and only affects calendar in IE11 when placeholder is applied. The underlying problem here is the way IE11 handles placeholder and field focus. When the focus is set/unset, the placeholder is removed/added which actually triggers onInput event (unlike other browsers).

p-calendar relies on this event and its actually blocking the other events so the date is not updated properly when selected in the datepicker for the first time.

There is no easy way of fixing that it seems (altho I think its fixed in Edge by Microsoft...). I have tried changing the 'onInput' binding to either one keypress/keyup/keydown and it seems to work for all browsers, although again in IE11 when you focus on the field initially to open datepicker, the placeholder will be removed and then when you select the date, the input loses focus and set the placeholder value back for split second before replacing that with the actual date value, so you end up with placeholder "flickering" for a moment.

external-olgierd avatar Feb 28 '17 15:02 external-olgierd

Hi

This workaround works form me. I added a directive:

`import { Directive, ContentChild, AfterContentInit } from '@angular/core'; import { Calendar } from 'primeng/primeng';

@Directive({ selector: 'p-calendar' }) export class CalendarOnFocusDirective implements AfterContentInit {

@ContentChild(Calendar) calendar: Calendar;

constructor() { }

ngAfterContentInit() { this.calendar.onFocus.subscribe( ev => { ev.target.offsetParent.focus(); } ) } } `

piowro avatar Mar 09 '17 11:03 piowro

@piowro That fixes an issue but have few side effects, the most major of which is the fact that you cant tab through calendar components in IE11 anymore.

external-olgierd avatar Mar 16 '17 08:03 external-olgierd

Tracked at;

https://github.com/primefaces/primeng/issues/2026

cagataycivici avatar Jun 20 '17 12:06 cagataycivici