Skip to content
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

bug: click event not fired on slotted buttons inside an ion-input that has focus #28762

Closed
3 tasks done
chadweimer opened this issue Dec 28, 2023 · 5 comments · Fixed by #28772
Closed
3 tasks done

bug: click event not fired on slotted buttons inside an ion-input that has focus #28762

chadweimer opened this issue Dec 28, 2023 · 5 comments · Fixed by #28772
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@chadweimer
Copy link

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

When using ion-button elements in the "end" slot of an ion-input, the buttons do not fire the click event when clicked while the ion-input has focus.

Expected Behavior

The click event should fire whether the input control has focus or not.

Steps to Reproduce

  1. Add an ion-input like the following
    <ion-item>
      <ion-input label="Input with buttons">
        <ion-button slot="end" onClick={...} >Click Me</ion-button>
      </ion-input>
    </ion-item>
  2. Click the button when the input control does not have focus - onClick fires
  3. Click the button when the input control has focus - onClick does not fire

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 5.4.16

Utility:

cordova-res : not installed
native-run : not installed

System:

NodeJS : v20.10.0
npm : 10.2.3
OS : Linux 6.1

Additional Information

No response

@ionitron-bot ionitron-bot bot added the holiday triage issues that were created during holiday period label Dec 28, 2023
Copy link

ionitron-bot bot commented Dec 28, 2023

Thanks for the issue! This issue has been labeled as holiday triage. With the winter holidays quickly approaching, much of the Ionic Team will soon be taking time off. During this time, issue triaging and PR review will be delayed until the team begins to return. After this period, we will work to ensure that all new issues are properly triaged and that new PRs are reviewed. In the meantime, please read our Winter Holiday Triage Guide for information on how to ensure that your issue is triaged correctly. Thank you!

@chadweimer
Copy link
Author

The workaround for this is to set the button with pointer-events: auto.

@liamdebeasi liamdebeasi self-assigned this Jan 2, 2024
@liamdebeasi
Copy link
Member

Thanks, I can reproduce this. Looks like this code is the culprit:

@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Jan 2, 2024
@ionitron-bot ionitron-bot bot removed the holiday triage issues that were created during holiday period label Jan 2, 2024
@liamdebeasi liamdebeasi removed their assignment Jan 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 3, 2024
Issue number: resolves #28762

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Focused inputs have `pointer-events: none`. This code was added in
e27452b
to address #5536.
However, this causes slotted buttons to not be clickable when the input
is focused because pointer events have been removed.

This also causes the input to blur whenever you tap the label text.

This behavior only exists on `ion-input`. Textarea is not affected.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

This code was added several years ago for the (now) legacy syntax. I
don't have full confidence that this won't break the legacy input
because there's not a lot of context around why specifically this code
was added. As a result, I scoped these styles only to the legacy input.
- Slotted buttons can now be clicked when the input is focused.
- Tapping the label when an input is focused keeps the input focused.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

**Testing:**

1. I manually verified that scroll assist still works with the modern
input.
2. I manually verified that the input remains focused after tapping the
label.

Dev build: `7.6.3-dev.11704229014.12cdc767`
@liamdebeasi
Copy link
Member

Thanks for the issue. This has been resolved via #28772, and a fix will be available in an upcoming release of Ionic Framework.

Copy link

ionitron-bot bot commented Feb 2, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants