-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(ion-button): sync disabled state in ion-button renderHiddenButton #31225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1d4c704
2964bc6
31aff31
c235b79
5fb20dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,41 @@ configs({ directions: ['ltr'], modes: ['ios'] }).forEach(({ title, config }) => | |
|
|
||
| expect(submitEvent).toHaveReceivedEvent(); | ||
| }); | ||
|
|
||
| test('should submit the form when disabled state changes asynchronously', async ({ page }, testInfo) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test does not actually catch the regression. It still passes without the fix. I verified by reverting the The reason is timing. The bug only happens when the There is no post-load DOM API to suppress the watch, so core e2e cannot reproduce this one deterministically. The faithful reproduction needs a framework binding that sets Please move the regression test to If you are feeling adventurous, add the same coverage to the standalone test app too.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thetaPC Thanks for the detailed feedback - it helps me learn and I appreciate it. I have a version of the test, in form.spec.ts that I would like to test before making the changes in button.tsx (mine plus the one you suggested in #31225 (comment)), to be pushed later once I can confirm it fails before the push. But, I am struggling to get e2e running in the Angular testing folder in a way that I wasn't when the test was in core. Any guidance? The link to Ionic's E2E testing guide is 404ing for me and I didn't quite know from the docs in https://github.com/ionic-team/ionic-framework/blob/main/docs/core/testing/README.md or https://github.com/ionic-team/ionic-framework/blob/main/docs/angular/testing.md about how to perform the E2E Angular tests specifically. |
||
| testInfo.annotations.push({ | ||
| type: 'issue', | ||
| description: 'https://github.com/ionic-team/ionic-framework/issues/30968', | ||
| }); | ||
|
|
||
| await page.setContent( | ||
| ` | ||
| <form> | ||
| <input type="text" /> | ||
| <ion-button type="submit" disabled>Submit</ion-button> | ||
| </form> | ||
| `, | ||
| config | ||
| ); | ||
|
|
||
| const submitEvent = await page.spyOnEvent('submit'); | ||
| const button = page.locator('ion-button'); | ||
|
|
||
| // Simulate async disabled state change — e.g. async validator resolving | ||
| await button.evaluate((el: HTMLIonButtonElement) => { | ||
| el.disabled = true; | ||
| setTimeout(() => { | ||
| el.disabled = false; | ||
| }, 0); | ||
| }); | ||
|
|
||
| // Wait for the async change to settle | ||
| await page.waitForTimeout(100); | ||
|
|
||
| await page.click('ion-button'); | ||
|
|
||
| expect(submitEvent).toHaveReceivedEvent(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(title('should throw a warning if the form cannot be found'), () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the following comment to reflect the changes and why they were added.