Skip to content

fix(toggle): trigger focus and blur on click #30234

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

Merged
merged 1 commit into from
Mar 10, 2025
Merged

fix(toggle): trigger focus and blur on click #30234

merged 1 commit into from
Mar 10, 2025

Conversation

thetaPC
Copy link
Contributor

@thetaPC thetaPC commented Mar 7, 2025

Issue number: N/A


What is the current behavior?

The blur and focus events do not trigger when clicking even though the value changes. Those events are only triggered when dragged.

This leads to Angular validation to not work accurately when clicking so the ion-touched is never added to the toggle since it relies on the blur event.

What is the new behavior?

  • The blur and focus events also trigger on click. This follows the same logic as ion-checkbox.

Does this introduce a breaking change?

  • Yes
  • No

Other information

How to test:

Recommendation to use toggle/test/basic/index.html: Preview

Add the following script:

<script>
  document.addEventListener('ionChange', () => {
    console.log('toggle: ionChange')
  });

  document.addEventListener('ionFocus', () => {
    console.log('toggle: ionFocus')
  });

  document.addEventListener('ionBlur', () => {
    console.log('toggle: ionBlur')
  });
</script>

Verify that the focus and blur events trigger when clicking and dragging.

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 9:18pm

@github-actions github-actions bot added the package: core @ionic/core package label Mar 7, 2025
@thetaPC thetaPC marked this pull request as ready for review March 7, 2025 21:35
@thetaPC thetaPC requested a review from a team as a code owner March 7, 2025 21:35
@thetaPC thetaPC requested review from ShaneK and brandyscarney March 7, 2025 21:35
@thetaPC thetaPC added this pull request to the merge queue Mar 10, 2025
Merged via the queue into main with commit ba8d8f4 Mar 10, 2025
51 checks passed
@thetaPC thetaPC deleted the toggle-focus branch March 10, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants