Skip to content

Commit 6b5c35a

Browse files
committed
chore(combo): rename focus handler and add comment. Correct test behavior
1 parent 964e22a commit 6b5c35a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<ng-container *ngIf="!isHeader">
2-
<igx-checkbox [checked]="selected" disableRipple="true" [disableTransitions]="disableTransitions" [tabindex]="-1" (click)="handleFocus($event)" class="igx-combo__checkbox"></igx-checkbox>
2+
<igx-checkbox [checked]="selected" disableRipple="true" [disableTransitions]="disableTransitions" [tabindex]="-1" (click)="disableCheck($event)" class="igx-combo__checkbox"></igx-checkbox>
33
</ng-container>
44
<ng-content></ng-content>

projects/igniteui-angular/src/lib/combo/combo-item.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ export class IgxComboItemComponent extends IgxDropDownItemComponent implements D
102102
/**
103103
* @hidden
104104
* @internal
105+
* The event that is prevented is the click on the checkbox label element.
106+
* That is the only visible element that a user can interact with.
107+
* The click propagates to the host and the preventDefault is to stop it from
108+
* switching focus to the input it's base on.
109+
* The toggle happens in an internal handler in the drop-down on the next task queue cycle.
105110
*/
106-
handleFocus(event: MouseEvent) {
111+
disableCheck(event: MouseEvent) {
107112
event.preventDefault();
108-
this.dropDown.element.focus();
109113
}
110114

111115
ngDoCheck() {

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const CSS_CLASS_DROPDOWNBUTTON = 'igx-combo__toggle-button';
2828
const CSS_CLASS_CLEARBUTTON = 'igx-combo__clear-button';
2929
const CSS_CLASS_CHECK_GENERAL = 'igx-combo__checkbox';
3030
const CSS_CLASS_CHECKBOX = 'igx-checkbox';
31+
const CSS_CLASS_CHECKBOX_LABEL = 'igx-checkbox__composite';
3132
const CSS_CLASS_CHECKED = 'igx-checkbox--checked';
3233
const CSS_CLASS_TOGGLE = 'igx-toggle';
3334
const CSS_CLASS_SELECTED = 'igx-drop-down__item--selected';
@@ -932,7 +933,7 @@ describe('igxCombo', () => {
932933
}
933934
function clickItemCheckbox(dropdownElement: any, itemIndex: number) {
934935
const dropdownItems = dropdownElement.querySelectorAll('.' + CSS_CLASS_DROPDOWNLISTITEM);
935-
const checkbox = dropdownItems[itemIndex].querySelector('.' + CSS_CLASS_CHECKBOX) as HTMLElement;
936+
const checkbox = dropdownItems[itemIndex].querySelector('.' + CSS_CLASS_CHECKBOX_LABEL) as HTMLElement;
936937
checkbox.click();
937938
}
938939
function verifyItemIsSelected(

0 commit comments

Comments
 (0)