Skip to content

Commit e60dcec

Browse files
renemadsenclaude
andcommitted
fix: use dispatchEvent('click') for MDC mat-checkbox interaction
MDC mat-checkbox has invisible label (zero-size) and input.click() doesn't trigger Angular change detection. dispatchEvent('click') on the mat-checkbox host element should trigger the Angular click handler properly. Also keep fallback to single-delete in clearTable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c999467 commit e60dcec

2 files changed

Lines changed: 11 additions & 41 deletions

File tree

eform-client/playwright/e2e/plugins/items-planning-pn/ItemsPlanningPairingPage.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ export class PairingRowObject {
142142
clickCancel = false
143143
) {
144144
if (clickOnPairRow) {
145-
await this.pairRowForClick.locator('input').evaluate((el: HTMLInputElement) => el.click());
145+
await this.pairRowForClick.dispatchEvent('click');
146146
await this.page.waitForTimeout(500);
147147
if ((await this.pairRow.locator('input').isChecked()) !== pair) {
148-
await this.pairRowForClick.locator('input').evaluate((el: HTMLInputElement) => el.click());
148+
await this.pairRowForClick.dispatchEvent('click');
149149
await this.page.waitForTimeout(500);
150150
}
151151
} else {
152152
for (let i = 0; i < this.pairCheckboxesForClick.length; i++) {
153153
if ((await this.pairCheckboxes[i].locator('input').isChecked()) !== pair) {
154-
await this.pairCheckboxesForClick[i].locator('input').evaluate((el: HTMLInputElement) => el.click());
154+
await this.pairCheckboxesForClick[i].dispatchEvent('click');
155155
await this.page.waitForTimeout(500);
156156
}
157157
}
@@ -164,7 +164,7 @@ export class PairingRowObject {
164164
indexDeviceForPair: number,
165165
clickCancel = false
166166
) {
167-
await this.pairCheckboxesForClick[indexDeviceForPair].locator('input').evaluate((el: HTMLInputElement) => el.click());
167+
await this.pairCheckboxesForClick[indexDeviceForPair].dispatchEvent('click');
168168
await this.page.waitForTimeout(1000);
169169
await this.pairingPage.savePairing(clickCancel);
170170
}
@@ -216,16 +216,16 @@ export class PairingColObject {
216216
clickCancel = false
217217
) {
218218
if (clickOnPairRow) {
219-
await this.pairColForClick.locator('input').evaluate((el: HTMLInputElement) => el.click());
219+
await this.pairColForClick.dispatchEvent('click');
220220
await this.page.waitForTimeout(500);
221221
if ((await this.pairCol.locator('input').isChecked()) !== pair) {
222-
await this.pairColForClick.locator('input').evaluate((el: HTMLInputElement) => el.click());
222+
await this.pairColForClick.dispatchEvent('click');
223223
await this.page.waitForTimeout(500);
224224
}
225225
} else {
226226
for (let i = 0; i < this.pairCheckboxesForClick.length; i++) {
227227
if ((await this.pairCheckboxes[i].locator('input').isChecked()) !== pair) {
228-
await this.pairCheckboxesForClick[i].locator('input').evaluate((el: HTMLInputElement) => el.click());
228+
await this.pairCheckboxesForClick[i].dispatchEvent('click');
229229
await this.page.waitForTimeout(500);
230230
}
231231
}

eform-client/playwright/e2e/plugins/items-planning-pn/ItemsPlanningPlanningPage.ts

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,9 @@ export class ItemsPlanningPlanningPage extends PageWithNavbarPage {
206206
if (!pickOne) {
207207
const isChecked = await this.selectAllPlanningsCheckbox.locator('input').isChecked().catch(() => false);
208208
if (isChecked !== valueCheckbox) {
209-
// Try multiple click strategies for MDC mat-checkbox
210-
const checkbox = this.selectAllPlanningsCheckbox;
211-
// Strategy: use Playwright's click with force on the label element
212-
const label = checkbox.locator('label');
213-
if ((await label.count()) > 0) {
214-
await label.click({ force: true });
215-
} else {
216-
await checkbox.click({ force: true });
217-
}
218-
await this.page.waitForTimeout(500);
219-
// Verify the click worked, if not try evaluate
220-
const nowChecked = await checkbox.locator('input').isChecked().catch(() => false);
221-
if (nowChecked === isChecked) {
222-
// Click didn't register, try JS click on the native control
223-
await checkbox.evaluate((el: HTMLElement) => {
224-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
225-
if (input) { input.click(); }
226-
});
227-
await this.page.waitForTimeout(500);
228-
}
209+
// MDC mat-checkbox label is invisible (zero-size). Dispatch click on the host element.
210+
await this.selectAllPlanningsCheckbox.dispatchEvent('click');
211+
await this.page.waitForTimeout(1000);
229212
}
230213
} else {
231214
const plannings = await this.getAllPlannings(0, false);
@@ -465,21 +448,8 @@ export class PlanningRowObject {
465448
async clickOnCheckboxForMultipleDelete(valueCheckbox = true) {
466449
const isChecked = await this.checkboxDelete.locator('input').isChecked().catch(() => false);
467450
if (isChecked !== valueCheckbox) {
468-
const label = this.checkboxDelete.locator('label');
469-
if ((await label.count()) > 0) {
470-
await label.click({ force: true });
471-
} else {
472-
await this.checkboxDelete.click({ force: true });
473-
}
451+
await this.checkboxDelete.dispatchEvent('click');
474452
await this.page.waitForTimeout(500);
475-
const nowChecked = await this.checkboxDelete.locator('input').isChecked().catch(() => false);
476-
if (nowChecked === isChecked) {
477-
await this.checkboxDelete.evaluate((el: HTMLElement) => {
478-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
479-
if (input) { input.click(); }
480-
});
481-
await this.page.waitForTimeout(500);
482-
}
483453
}
484454
}
485455

0 commit comments

Comments
 (0)