-
Notifications
You must be signed in to change notification settings - Fork 115
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
Emit an input event primer-text-field#clearContents. #3062
Conversation
Having the `#clearContents` emit an `input` event, it integrates better whenever an `input` event listener is bound to the `primer-text-field` components. A classic example is to use the `primer-text-field` as a search field, which triggers a background request when the field's value is changed. Without emiting the `input` event on #clearContents, the filtering background request would not be triggered.
🦋 Changeset detectedLatest commit: b7bb9fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Awesome, thank you! Just a few small things, then this is good to 🚀
Co-authored-by: Cameron Dutro <[email protected]>
Ah I forgot to mention this last time @dombesz, but could you also add a changeset? Running |
@camertron I already have 1 here, do I need to add a new one? |
Ah sorry I missed it, carry on! |
What are you trying to accomplish?
I want to make the
primer-text-field
clear button to trigger aninput
event in the field. This makes the clear button logic to behave the same way as it was deleted by the user manually.A good example for this behaviour is to use the
primer-text-field
as a search field, triggering a background request to refresh the results when its value is changed. Without emitting theinput
event on the#clearContents
, refreshing the results would not be triggered.A possible workaround would be to bind the background request directly on the clear button too. Unfortunately there is no simple way to bind events to the clear button, because event binding to the clear button is not possible via the
primer-text-field
component declaration.Integration
Does not require any code change in production.
List the issues that this change affects.
Closes #3061
Risk Assessment
What approach did you choose and why?
The solution is trigger an
input
event when theprimer-text-field
clear button is clicked.Merge checklist
Added/updated documentationAdded/updated previews (Lookbook)Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.