Make filters survive a shared link
Build URL-backed catalog filters with a native GET form, then test the difference between a fresh shared link and browser history restoration.

You narrow a resource library to frontend guides, copy the address and send it to a teammate. They open the whole library. The cards changed on your screen, but the address never learned what you chose. A filter is only shareable when the destination can reconstruct its applied state.
For a read-only catalog, start with a small URL contract and an ordinary GET form. Let the server read those parameters, filter the data and render the selected controls. Then decide whether faster client navigation would improve the experience. This gives the interface a useful baseline before any client script runs.
Make the address describe the applied view
Fresh navigation with JavaScript disabled. The server receives topic=frontend&format=guide and renders two matching resources. The green request panel is demo output, not browser chrome.In the study, /resources means the full shelf. Adding ?topic=frontend&format=guide selects two records: Layout field guide and Component boundaries. Those are sample entries, not product claims. The server renders the result count, the applied summary and the initial dropdown choices from the same parsed values.
The HTML standard defines GET submission as sending the form data in the URL. The form element reference explains the action destination and method. This fits a filter that retrieves a view without changing stored records. The server still needs an implementation for that destination; a form tag alone cannot search a database.
Where should a filter choice live?
Only in component memory
Useful for a temporary editing choice.
- A fresh visit has no record of the applied view.
- Sharing the current address may open the default catalog.
- Persistence needs an explicit design decision.
In the applied URL
Useful for a view people revisit or share.
- A fresh request can reconstruct the filter criteria.
- The same parser can drive results and selected controls.
- The link describes criteria; changing data can still change results.
Give the URL a small, explicit vocabulary
Write down allowed values before wiring controls. In this fixture, missing, blank or unknown values fall back to all. If a single-choice parameter appears twice, the first value wins. These are deliberate rules for this demo, not behavior that every framework supplies. A larger product may prefer a visible invalid-filter message.
The demo’s URL contract| Key | Accepted values | Default / repeated input |
|---|
| topic | all, frontend, design | all; first value wins |
| format | all, guide, workshop | all; first value wins |
| Other keys | Ignored by this fixture | Do not change the result set |
Use a query parser rather than splitting strings around ampersands. In JavaScript, URLSearchParams offers get() for the first value and getAll() for every value under a key. Match that choice to the control: a single dropdown and a multi-select checklist need different rules. Validate decoded values against the vocabulary before using them.
Keep unrelated state intentional too. A new filter normally starts a paginated list at its first page; a pagination link should carry the active filters forward. This small study has no pagination. In your application, name which parameters survive each action so a stale page number cannot quietly produce a misleading view.
Let the form make the request
Each select has a name for submission and a label associated with its id. W3C’s labeling guidance describes that explicit relationship. A visible Apply filters button lets someone choose several values before navigating. This example does not submit merely because a dropdown changes.
<form action="/resources"
method="get">
<label for="topic">Topic</label>
<select id="topic" name="topic">
<option value="all">
All topics
</option>
<option value="frontend"
selected>
Frontend
</option>
<option value="design">
Design
</option>
</select>
<button type="submit">
Apply filters
</button>
</form>
This excerpt shows the topic control after a frontend request. The full demo also includes format. On each fresh response, the server chooses the selected option from the parsed URL; selected is not a permanent property of Frontend. Keep every filter you intend to submit inside the form, or explicitly associate it with that form.
Clear filters is an ordinary link to /resources. A reset button would return controls to their initial values for the current page; it would not navigate to the unfiltered view. Naming the action clearly helps reviewers catch that difference before styling makes both controls look interchangeable.
Separate applied results from editable choices
Observed in Chromium: Back returns to the Guide results, but the editable Format control restores Workshop. The applied summary still identifies the results being shown.The test first opened Frontend / Guide, changed Format to Workshop, submitted, and went Back. Chromium and WebKit restored Workshop in the dropdown while the URL, applied summary and two cards returned to Guide. Firefox showed Guide in the control. That difference appeared at all three tested widths; it is an observation of these browser builds, not a universal compatibility promise.
MDN’s history-navigation explanation notes that persisted user state can include form values. A fresh shared link and a history-restored document are therefore different review cases. Treat controls as the next editable request, and label the criteria that produced the displayed results. If your product requires both to stay synchronized, implement and test that behavior explicitly.
Fresh 390 CSS-pixel context, JavaScript disabled. Reopening the shared URL restores both initial controls and results; the form stacks without horizontal page overflow.Review the journey before adding enhancement
The fixture passed nine runs across Chromium, Firefox and WebKit at 820, 390 and 320 CSS pixels, with page JavaScript disabled. Keyboard submission, reload, fresh-context sharing, result restoration through Back/Forward, clearing, unknown-value fallback and repeated-value handling were checked. The browser-specific dropdown restoration above is retained in the evidence.
A practical filter review
Apply by keyboard
Choose two filters, focus Apply filters and press Enter. Check the URL, count, applied summary and cards together.
Reopen the address
Paste the resulting URL into a fresh browser context. Compare the initial controls and results, then reload.
Traverse history
Apply a second view, go Back, then Forward. Inspect editable controls separately from the applied summary.
Exercise the boundaries
Try a narrow screen, an unknown value, repeated parameters and Clear filters. Confirm each outcome follows the written contract.
A client router can later make the same journey feel smoother. Keep the URL contract and add checks for loading feedback, focus and history. A useful handoff is concrete: “Preserve these filter URLs, render the same initial results on a fresh request, and show which criteria are applied.” That gives a designer, developer or AI editor a behavior they can demonstrate.
Back to the LOOKFILE blog