[Feature request] Updating / removing query params from the url

Open
#458 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
frontend, web-dev

Research direction

Start by tracing the documented go to url behavior, especially variable-based URLs, and compare it with the issue's window.history.pushState example. Define a supported way to update or remove query parameters without navigation, including the requested view removal, and verify that the behavior is documented and covered by examples or tests.

Written by the indexing model from the issue text.

Description

Hi there,

Again - I want to express my ❤️ for _hyperscript!

One thing I'm struggling with is removing a query parameter from the url. I tried lots of things but this is what I ended up with:

<button class="modal-close is-large"
            _="on click remove #company-edit-modal
                js
                    window.history.pushState({}, document.title, window.location.pathname);
                end"
            aria-label="close"></button>

My journey started as follows:

<button class="modal-close is-large"
            _="on click log the location of window
                then set newLocation to the location of window
                then log newLocation.origin + newLocation.pathname
                then set newLocationUrl to newLocation.origin + newLocation.pathname
                then log newLocationUrl
                then go to url #(newLocationUrl)
            "
            aria-label="close"></button>

I just want to update the url and not navigate so according to the docs it should be possible by prepending it with a hash. However, this does not appear to be working with variables.

But how cool 😎 would the following be:

<button class="modal-close is-large"
            _="on click remove #company-edit-modal then remove query param 'view' from the url"
            aria-label="close"></button>

I tried a lot of the combinations above but none worked so I assume this is not implemented.

Dominant language
JavaScript
Stars
3.8k
Forks
171
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bigskysoftware/_hyperscript

All issues in bigskysoftware/_hyperscript

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.