From 48b2ed48e1a67c3e7e48da1548e96ed489247d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Klas=C3=A9n?= Date: Thu, 1 Oct 2020 11:16:06 +0200 Subject: [PATCH 1/3] If lastSelectedIndex is greater than items in array set it to last in array. --- .../src/lib/controls/filter-tag/filter-tag-group.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag-group.component.ts b/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag-group.component.ts index 4b16a40e3..3c36b4a3f 100644 --- a/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag-group.component.ts +++ b/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag-group.component.ts @@ -46,6 +46,7 @@ export class FilterTagGroupComponent implements AfterContentInit, OnDestroy { if (this.lastSelectedIndex < nonRemovedFilterTags.length) { nonRemovedFilterTags[this.lastSelectedIndex].focus(); } else if (nonRemovedFilterTags.length) { + this.lastSelectedIndex = nonRemovedFilterTags.length - 1; nonRemovedFilterTags[nonRemovedFilterTags.length - 1].focus(); } } From 1f9704615db7679b07e760606cc60edc4ea3c31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Klas=C3=A9n?= Date: Thu, 1 Oct 2020 11:17:11 +0200 Subject: [PATCH 2/3] Add delay before focus in IE11. --- .../controls/filter-tag/filter-tag.component.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts b/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts index aecdceb45..403faf795 100644 --- a/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts +++ b/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts @@ -41,7 +41,22 @@ export class FilterTagComponent implements AfterViewInit { } focus() { - this.filtertag.nativeElement.focus(); + // TODO: Remove this as soon as IE11 + // support is dropped. + // + // focus() does not work in IE11 unless + // set after a short delay. Wrap in if + // to not do this in better browsers. + const re = /Trident\/7/; + const isIE11 = re.test(window.navigator.userAgent); + + if (isIE11) { + setTimeout(() => { + this.filtertag.nativeElement.focus(); + }, 5); + } else { + this.filtertag.nativeElement.focus(); + } } emitRemove() { From 1a0e5d73f0fb455695ed1b592f981d9c7c638d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Klas=C3=A9n?= Date: Thu, 1 Oct 2020 15:20:59 +0200 Subject: [PATCH 3/3] Update comment on IE11 hack --- .../src/lib/controls/filter-tag/filter-tag.component.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts b/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts index 403faf795..22ff0f2d9 100644 --- a/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts +++ b/projects/komponentkartan/src/lib/controls/filter-tag/filter-tag.component.ts @@ -41,11 +41,8 @@ export class FilterTagComponent implements AfterViewInit { } focus() { - // TODO: Remove this as soon as IE11 - // support is dropped. - // // focus() does not work in IE11 unless - // set after a short delay. Wrap in if + // called after a short delay. Wrap in if // to not do this in better browsers. const re = /Trident\/7/; const isIE11 = re.test(window.navigator.userAgent);