ngx-bootstrap icon indicating copy to clipboard operation
ngx-bootstrap copied to clipboard

feat(timepicker) - add keyboard navigation

Open nadavten opened this issue 10 years ago • 7 comments

bug

timer - arrowKeys not working.

and i dont see the arrows (up and down) for each input of hour:minutes

nadavten avatar Sep 20 '16 20:09 nadavten

Setting [arrowkeys]="false" doesn't seem to change any behavior for me either.

Are you sure you don't have [showSpinners]="false"? That removes the up down arrow chevrons.

zacharybil avatar Oct 03 '16 20:10 zacharybil

Im sure

On Mon, Oct 3, 2016, 23:43 Zachary Billington [email protected] wrote:

Setting [arrowkeys]="false" doesn't seem to change any behavior for me either.

Are you sure you don't [showSpinners]="false"? That removes the up down arrow chevrons.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/valor-software/ng2-bootstrap/issues/1007#issuecomment-251220907, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ-rrFThv6nMUZZU8B3rnAP6nfi4XHNBks5qwWjlgaJpZM4KCIfH .

nadavten avatar Oct 04 '16 11:10 nadavten

Pressing the arrow keys on my Macbook Air (macOS Sierra) in the latest Chrome does not change the value in the timepicker, even if I explicitly state [arrowkeys]="true". It does not work on the demo page for me, either: https://valor-software.com/ng2-bootstrap/#/timepicker

SystemDisc avatar Jan 19 '17 11:01 SystemDisc

It may be that pressing up by default puts the cursor at the beginning of the input and down puts it at the end. Perhaps you need to e.preventDefault();

SystemDisc avatar Jan 19 '17 11:01 SystemDisc

'arrowkeys' property is not working for me either. Is it fixed yet? or is there something I may be missing?

rishuvaid avatar Mar 15 '17 21:03 rishuvaid

It's still not working.

I ended up putting a hacky jQuery script in a plain JS file that I link to in my header.

$(function() {
	$(document).on('keydown', 'timepicker input[type=text], timepicker button', function(e) {
		if (e.keyCode === 38 || e.keyCode === 40) {
			e.preventDefault();
			e.stopPropagation();
			let $this = $(e.currentTarget);
			let index = $this.closest('td').index();
			if ($this.is(':not(button)')) {
				if (e.keyCode === 38) {
					$this.closest('table').find('tr').first().find('td:nth-child(' + (index + 1) + ') a > *').first().click();
				}
				else {
					$this.closest('table').find('tr').last().find('td:nth-child(' + (index + 1) + ') a > *').first().click();
				}
			}
			else {
				$this.click();
			}
		}
	});
});

This works even with the buttons hidden.

SystemDisc avatar Mar 16 '17 20:03 SystemDisc

fixed in #2058

IlyaSurmay avatar Jul 28 '17 12:07 IlyaSurmay