question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update results when clicking the <input type="search">'s reset icon

See original GitHub issue

I guess this is more a htmx thing, but when using a <input type="search"> input, the native reset cross icon that appears inside the corner of the field is not reactive.

I mean, this clear the input value as expected, but does not update the results like the s-trigger does on keyup: <input type="search" id="keywords" name="keywords" value sprig s-trigger="keyup changed delay:300ms" s-replace="#results" placeholder="keywords" autocomplete="off" spellcheck="false">

I would like it to update the results like if we erase all the text in the field. How can I do, while maintaining the update on keyup? On top of that, I need that the ?page=x query param is reset, so removed from the URL.

The demos in the doc are using simply <input type="text"> instead of <input type="search"> inputs.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
romainpoiriercommented, Jul 28, 2022

I was asking this because {% do sprig.pushUrl('?') %} within the {{ sprig() }} template was replacing the entire path with ?, so I was getting website.dev/? instead of website.dev/section?. Adding {% do sprig.pushUrl('?') %} before/inside/after the sprig form did the same result. I finally found this solution (or workaround) bellow.

Pass craft.app.request.getFullPath as param to the {{ sprig() }} template:

{{ sprig('_sprig/agenda', {
	path: craft.app.request.getFullPath,
	limit: 5
}) }}

Within the {{ sprig() }} template, add this on top of the file:

{% if page ?? 1 == 1 %}
	{% do sprig.pushUrl(path) %}
{% endif %}

This make the path working correctly, and on top of that I’m not getting the unwanted ? empty query param. This is a simple reset solution, as I’m not dealing with other query params that the ?page=x.

1reaction
bencrokercommented, Jul 27, 2022
  1. {% do sprig.pushUrl('?') %} will set the URL to the current path, with ? at the end.
  2. Not that I know of.
  3. See the video series on Sprigboard, which contains both a search field and pagination: https://putyourlightson.com/sprig/videos#sprigboard
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you detect the clearing of a "search" HTML5 input?
Simply add a listener for 'input' on your search input which will capture when the user types something in the input or clicks...
Read more >
<input type="reset"> - HTML: HyperText Markup Language
Try entering some text into the text field, and then pressing the reset button. Adding a reset keyboard shortcut. To add a keyboard...
Read more >
Targeting Click of “Clear” Button (X) on Input Field
Everything is working as you expect – you can enter text into the search box, hit enter or the "Search" button, and see...
Read more >
How to Remove “X” icon from search input field or input type ...
The Solution to Remove this X icon: /* clears the 'X' from Internet Explorer */ input[type=search]::-ms-clear { display: none; width : 0; ...
Read more >
lightning-input - documentation - Salesforce Developers
Checkboxes let you select one or more options. lightning-input type="checkbox" is useful for creating single checkboxes. If you are working with a group...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found