Skip to content

Commit 2e5548c

Browse files
committed
fix(tags): tag-input affects another focused input (#UIM-723) (#707)
* fix(tags): tag-input affects another focused input (#UIM-723) * deleted code for debug
1 parent 9941006 commit 2e5548c

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

packages/mosaic/tags/tag-list.component.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -796,36 +796,37 @@ export class McTagList extends McTagListMixinBase implements McFormFieldControl<
796796

797797
/** Listens to user-generated selection events on each tag. */
798798
private listenToTagsFocus(): void {
799-
this.tagFocusSubscription = this.tagFocusChanges.subscribe((event) => {
800-
const tagIndex: number = this.tags.toArray().indexOf(event.tag);
799+
this.tagFocusSubscription = this.tagFocusChanges
800+
.subscribe((event) => {
801+
const tagIndex: number = this.tags.toArray().indexOf(event.tag);
801802

802-
if (this.isValidIndex(tagIndex)) {
803-
this.keyManager.updateActiveItem(tagIndex);
804-
}
803+
if (this.isValidIndex(tagIndex)) {
804+
this.keyManager.updateActiveItem(tagIndex);
805+
}
805806

806-
this.stateChanges.next();
807-
});
807+
this.stateChanges.next();
808+
});
808809

809-
this.tagBlurSubscription = this.tagBlurChanges.subscribe(() => {
810-
this.blur();
811-
this.stateChanges.next();
812-
});
810+
this.tagBlurSubscription = this.tagBlurChanges
811+
.subscribe(() => {
812+
this.blur();
813+
this.stateChanges.next();
814+
});
813815
}
814816

815817
private listenToTagsRemoved(): void {
816-
this.tagRemoveSubscription = this.tagRemoveChanges.subscribe((event) => {
817-
const tag = event.tag;
818-
const tagIndex = this.tags.toArray().indexOf(event.tag);
819-
820-
// In case the tag that will be removed is currently focused, we temporarily store
821-
// the index in order to be able to determine an appropriate sibling tag that will
822-
// receive focus.
823-
if (this.isValidIndex(tagIndex) && tag.hasFocus) {
824-
this.lastDestroyedTagIndex = tagIndex;
825-
} else if (this.isValidIndex(tagIndex) && !tag.hasFocus) {
826-
this.focusInput();
827-
}
828-
});
818+
this.tagRemoveSubscription = this.tagRemoveChanges
819+
.subscribe((event) => {
820+
const tag = event.tag;
821+
const tagIndex = this.tags.toArray().indexOf(event.tag);
822+
823+
// In case the tag that will be removed is currently focused, we temporarily store
824+
// the index in order to be able to determine an appropriate sibling tag that will
825+
// receive focus.
826+
if (this.isValidIndex(tagIndex) && tag.hasFocus) {
827+
this.lastDestroyedTagIndex = tagIndex;
828+
}
829+
});
829830
}
830831

831832
/** Checks whether an event comes from inside a tag element. */

packages/mosaic/tags/tag.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ export class McTagRemove {
422422
/** Calls the parent tag's public `remove()` method if applicable. */
423423
handleClick(event: Event): void {
424424
if (this.parentTag.removable) {
425+
this.parentTag.hasFocus = true;
426+
425427
this.parentTag.remove();
426428
}
427429

0 commit comments

Comments
 (0)