Skip to content

Suggest in-region popularity queries without rewriting them - #555

Closed
inverteum wants to merge 1 commit into
browserslist:mainfrom
inverteum:feat/446-in-region-query-banner
Closed

inverteum wants to merge 1 commit into
browserslist:mainfrom
inverteum:feat/446-in-region-query-banner

Conversation

@inverteum

Copy link
Copy Markdown

Closes #446.

Summary

Suggest a region-aware popularity query when the Region selector and the typed query disagree. The banner is only a suggestion. It does not rewrite the textarea, and it does not change the Region selector.

That follows the rejection of #444. >1% has to return the same browser list for every Region value. Automatically inserting in REGION hid the fact that the result changed. The selector stays a coverage argument in server/lib/get-browsers.js.

Banners

Both banners render in [data-id=form_messages], next to the existing lint messages, and are removed on the next submit the same way those messages are.

  1. Country selected, global popularity query. The selector is a country (not Global alt-ww, and not a continent such as alt-as). The query has a browserslist popularity clause: >, >=, <, or <=, with the spacing browserslist already accepts (>= 1%, >=1%, > 1%, >1%, and the same forms with normal spacing). The banner recommends the same clause with in REGION, for example >= 1% in FR. A clause that already says in REGION is not recommended again.

  2. in REGION while the selector is Global. The query already has a popularity clause in a country or continent, and the selector is Global. The banner names that region and tells the user to choose it in the Region selector. It does not set the <select>. in alt-ww is not suggested, because that is already Global. in my stats and cover are not treated as this case.

< and <= are included because they are the same browserslist popularity / popularity_in_place query type as > and >=. A space before % (>= 1 %) is not, because browserslist does not parse that as a popularity query.

Why nothing is applied for the user

The existing buildWarning “Fix” link writes a new q into the hash. This banner does not use that link. The recommended query is text. The Region sentence points at the selector and leaves its value alone. Region changes still call submitForm() and still do not edit the textarea.

Tests

Client checks in client/test/region-query-banner.test.js cover both directions and the non-cases (Global plus a plain >= N%, a continent, and a query that already has in REGION). They run with node --test and do not start the site. server/test/browsers.test.js checks that >1% and >= 1% keep the same browser names and versions for global, alt-ww, alt-eu, US, and FR.

pnpm test on this commit did not finish: prebuild:stats got GitHub API 403 while fetching star counts. The checks below were run separately with Node 26.12.1 and pnpm 12.15.0 and passed: client test:run (19), server test:run (19), oxlint ., stylelint ., node scripts/check-versions.js, pnpm audit --prod, vite build, and size-limit. The script budget in client/.size-limit.json is 16 KB (built script 15.33 KB). The download budget is still 60 KB (59.7 KB brotli).

A country in the Region selector plus a global popularity query now
shows a banner suggesting `>= N% in REGION`. A query that already uses
`in REGION` while the selector is Global suggests choosing that region
in the selector. The query and the selector stay as the user set them,
so `>1%` still returns the same browsers for every region. Rewriting
the query was rejected in browserslist#444.

Closes browserslist#446.
@ai

ai commented Nov 18, 2026

Copy link
Copy Markdown
Member

Can you show screenshot?

@inverteum

Copy link
Copy Markdown
Author

Both directions, from this branch. The suggestion is the yellow note without a Fix link. It does not rewrite the query or change the Region selector. The note with Fix is the existing coverage warning.

United States, query >= 1%:

Region United States and query >= 1%, suggesting >= 1% in US

Global, query >= 1% in US:

Region Global and query >= 1% in US, suggesting United States in the selector

@ai

ai commented Nov 18, 2026

Copy link
Copy Markdown
Member

Sorry, even with the screenshot I can't get what do you suggest.

Can you tell me a simple step-by-step example?

@inverteum

Copy link
Copy Markdown
Author

Example for #446. The note only suggests a change. It does not edit the query or the Region selector.

Country selected, query has no region:

  1. Set Region to United States.
  2. Type >= 1%.
  3. The query stays >= 1%, and Region stays United States. The browsers are still the ones for global >= 1%. Region only changes the coverage numbers.
  4. A yellow note with no Fix link says: Region is United States. Try >= 1% in US.
  5. >= 1% in US means popularity in the United States. The note does not type it for you.

Query already has a region, selector is Global:

  1. Set Region to Global.
  2. Type >= 1% in US.
  3. The query stays >= 1% in US, and Region stays Global.
  4. A yellow note with no Fix link says: >= 1% in US. Region is Global. Choose United States in the Region selector.
  5. The note does not change the selector. Pick United States yourself if you want the coverage numbers for that country.

A yellow note that has a Fix link is the existing coverage warning.

@ai

ai commented Nov 19, 2026

Copy link
Copy Markdown
Member

Sorry, your messages require a lot of my effort to be understood. Can you explain in a simple manner what do you want to fix?

@inverteum

Copy link
Copy Markdown
Author

We want to fix this mix-up: with Region set to United States, >= 1% still lists globally popular browsers, not browsers popular in the US. We show a note recommending >= 1% in US, and we leave the query as typed. If the query is already >= 1% in US and Region is Global, the note recommends choosing United States.

@ai

ai commented Nov 19, 2026

Copy link
Copy Markdown
Member

= 1% still lists globally popular browsers, not browsers popular in the US

No. It is REPL for Browserslist. It should show what Browserslist output on exactly the same query.

@ai ai closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Promote in REGION query on region selector value

2 participants