Build

A filter link should reopen the same list

A fictional notes directory has six entries. You select Design and Motion, choose descending order and see four notes. The address looks shareable. When it is opened again, only the two Design notes appear. The query still contains both choices; the part that reads it has quietly discarded the second one.

A saved filter is a small agreement between the controls, the URL and the result. Reviewing the controls alone misses that agreement. Reviewing the address alone misses it too. The useful question is whether opening the address reconstructs the intended selection and ordering from the same records.

Decide what the selection means

For this article, each fictional note has one topic: Design, Motion or Build. Selecting two topics means either topic is acceptable. It is a union. Requiring every selected topic would produce a different result because no note belongs to two topics in this dataset.

The remaining rules are equally deliberate. No topic selection means all six notes. A repeated known topic is treated as one selection. An empty or unsupported topic produces an error instead of silently expanding to the full list. Sorting defaults to ascending ID only when the sort key is absent. Unsupported or repeated sort values also produce an error.

These are the fixture's rules, not requirements imposed by a browser API. A different product can choose different rules, but its controls, reader and review record need to agree about them.

ItemRule in this fictional directory
Two selected topicsInclude a note belonging to either topic
No selected topicsInclude all topics
Same topic twiceTreat it as one choice
Empty or unknown topic valueShow an unsupported-filter error
Missing sort keyAscending ID
Two sort valuesShow an unsupported-filter error

Let the form describe the request

The local browser fixture used ordinary forms with method="get". It had no page scripts. Each topic checkbox used the name topic and its own value. Both checked topics therefore appeared under the same key in the submitted query:

?topic=design&topic=motion&sort=id-desc

MDN's form reference describes GET form data being appended to the action URL, and reserves this method for forms without side effects. The fixture only reads six invented notes. It does not save a preference, edit a record or send a message.

The checkbox reference explains another detail that matters here: unchecked checkboxes are not submitted. The request does not contain topic=build with a false value. It omits that choice. This is why the meaning of an absent topic needs to be decided before implementing the reader.

The browser has transmitted both selected values in the example. The remaining job is to read all of them, apply the stated rules, and render the controls from that same interpreted state.

Run the six-note comparison

Save the following as filter-model.mjs and run node filter-model.mjs. It contains the complete fictional dataset and query cases. It performs no filesystem or network writes and needs no packages. The intended reader leaves firstOnly false; the true setting is an intentionally faulty comparison that demonstrates losing a repeated value.

AI assistance was used to prepare the fixture, check the observations and draft this explanation. The code was executed with Node.js 26.11.1 on November 11, 2026. These are original local synthetic observations, not customer behaviour or results from a live product.

// Fictional records; pure query interpretation, no filesystem/network writes.
export const records = [
  { id: 'R01', topic: 'design', title: 'Red type' },
  { id: 'R02', topic: 'motion', title: 'Quiet fade' },
  { id: 'R03', topic: 'build', title: 'Static page' },
  { id: 'R04', topic: 'design', title: 'Blue grid' },
  { id: 'R05', topic: 'motion', title: 'Gentle loop' },
  { id: 'R06', topic: 'build', title: 'Link check' }
];
export const allowedTopics = ['design', 'motion', 'build'];
const allowedSorts = ['id-asc', 'id-desc'];

export function readView(query, firstOnly = false, rows = records) {
  const params = new URLSearchParams(query);
  const rawTopics = params.getAll('topic');
  const rawSorts = params.getAll('sort');
  const invalid = rawTopics.some(t => !allowedTopics.includes(t))
    || rawSorts.length > 1
    || rawSorts.some(s => !allowedSorts.includes(s));
  if (invalid) return { error: 'Unsupported filter', topics: [], ids: [] };
  // firstOnly is an intentionally faulty comparison, not the proposed reader.
  const chosen = firstOnly && rawTopics.length
    ? [params.get('topic')] : rawTopics;
  const topics = [...new Set(chosen)];
  const sort = rawSorts[0] ?? 'id-asc';
  const result = rows.filter(r => !topics.length || topics.includes(r.topic))
    .toSorted((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
  if (sort === 'id-desc') result.reverse();
  return { topics, sort, ids: result.map(r => r.id) };
}

export const cases = [
  ['omitted', ''],
  ['two topics', 'topic=design&topic=motion&sort=id-desc'],
  ['reversed topics', 'topic=motion&topic=design&sort=id-desc'],
  ['duplicate topic', 'topic=design&topic=design'],
  ['empty topic', 'topic='],
  ['unknown topic', 'topic=unknown'],
  ['unknown sort', 'sort=newest'],
  ['repeated sort', 'sort=id-asc&sort=id-desc']
];

for (const [name, query] of cases) {
  console.log(name, JSON.stringify(readView(query)));
}
const query = cases[1][1];
console.log('first value only', JSON.stringify(readView(query, true)));
console.log('changed records', JSON.stringify(readView(query, false, [
  ...records, { id: 'R07', topic: 'motion', title: 'New fictional note' }
])));

MDN documents getAll() as returning all values associated with a key. The faulty comparison deliberately selects only the first topic. With Design first, it returns R04, R01; reversing the topic values makes it return the Motion records R05, R02. The complete reader returns R05, R04, R02, R01 in both cases.

This comparison separates two kinds of order. The selected topics do not have a priority in the stated union rule. The result order does: descending ID is part of the saved view. A reader that happens to return the right count while changing that order has still failed this particular agreement.

Local query caseResult from the complete reader
No queryR01, R02, R03, R04, R05, R06
Design and Motion, descendingR05, R04, R02, R01
Motion and Design, descendingR05, R04, R02, R01
Design repeated twiceR01, R04
Empty topicUnsupported-filter error
Unknown topicUnsupported-filter error
Unknown sortUnsupported-filter error
Repeated sortUnsupported-filter error

Check the browser response as well

The same reader function supplied two local server routes. One used its complete interpretation; the comparison route deliberately enabled the first-value fault. Both rendered the chosen checkboxes, sort control and result list from the returned state. A response policy disallowed page scripts, and the recorded pages contained no script elements.

The planned native observations used desktop 1440 × 900 and narrow 390 × 844 viewports. At each width, the unfiltered routes began with six notes. Applying Design and Motion in descending order returned four notes on the complete route and two on the faulty route. The complete route retained both checked topics and the descending order after reload and when its resulting address was opened in a fresh tab.

There were twelve planned state reads and one extra fresh-tab read at the browser's default 1280-pixel width. That extra read also returned the four expected notes; it was kept separately rather than described as one of the 1440- or 390-pixel observations. Desktop topic and Apply actions used pointer clicks. Narrow topic choices used Space and the Apply button used Enter; sorting used the browser's native select control.

Native action at each planned widthComplete readerFirst-value comparison
Open without a querySix notesSix notes
Apply Design and Motion, descendingFour notes; both topics checkedTwo notes; only Design checked
Reload the completed viewSame four IDs, topics and orderNot tested
Open that address in a fresh tabSame four IDs, topics and orderNot tested

The query in the faulty response still contained both topics. That makes the defect easy to miss in a review that checks only whether the address changed. Comparing the requested values with both the rendered controls and the exact returned IDs exposes where the disagreement occurs.

A saved view is not a frozen list

One final local control added a seventh fictional note, R07, with the Motion topic. The same two-topic descending query then returned five notes, beginning with R07. The reader still applied the same selection correctly. The underlying records had changed.

That boundary matters when someone uses a link to discuss a count. Record the dataset version or capture time alongside the expected IDs if reproducing a particular observation matters. A filter URL by itself is not an export, an audit record or proof that another person can access the same records.

Keep sensitive information out of proposed filter examples and choose deliberately what belongs in a shareable address. This fixture uses public-style topic labels and invented notes. It does not test access rules, authentication or the handling of private search terms. Its small value checks are not a general security review.

Leave a review record someone can repeat

A practical handoff has five fields: the complete view address; the selection and ordering rules; the dataset version or fixed test records; the expected ordered IDs and selected controls; and the actions actually checked. For this fixture, those actions are Apply, Reload and fresh-tab opening. Browser Back and Forward are separate unchecked items, not implied passes.

Add explicit expected behaviour for missing, empty, repeated and unsupported values to that record. If the interface uses client-side routing, test that implementation independently. The no-script server responses here say nothing about a router restoring component state or an application preserving focus after an update.

Before accepting a saved-view feature, compare all three outputs together: what the address requests, what the controls show, and which records appear in which order. The resulting note is useful to the next person reviewing the feature because it describes an observable outcome they can reproduce, with the limits of the check still visible.

Questions and answers

Does a filter URL preserve a snapshot of the results?

No. It can preserve the selection and ordering rules. The records, permissions or application rules may change before the link is reopened. A stable snapshot needs its own explicit versioning or export design.

What should no selected topics mean?

That is a product decision. In this fictional fixture, no selected topic means all topics. Other interfaces may require an explicit selection. Write the rule down and show it beside the controls.

Does this test prove that browser Back and Forward work?

No. The native experiment covered form submission, reload and opening the resulting URL in a fresh tab. Back and Forward, client-side routing and assistive technology need their own checks.

Sources

  1. URLSearchParams.getAll() (MDN) developer.mozilla.org
  2. The form element and GET method (MDN) developer.mozilla.org
  3. Checkbox submission behaviour (MDN) developer.mozilla.org