Skip to content

Register the A-Z letter parameter as a search request (GVAZ-1) - #65

Open
zackkatz wants to merge 4 commits into
developfrom
fix/az-search-request
Open

Register the A-Z letter parameter as a search request (GVAZ-1)#65
zackkatz wants to merge 4 commits into
developfrom
fix/az-search-request

Conversation

@zackkatz

@zackkatz zackkatz commented Jul 15, 2026

Copy link
Copy Markdown
Member

Linear: Closes GVAZ-1. Related: GVIEW-296 (GravityView core awareness), GVDT-44 (DataTables).

The A-Z Entry Filter widget filters entries by first letter through the letter GET parameter and its own gravityview/view/query GF_Query condition, but it never told GravityView that letter is a search. So core's is_search() ignored ?letter=.

The bug

A View set to "Hide entries until search" stays hidden when a visitor clicks an A-Z letter, because the renderer withholds entries until gravityview()->request->is_search() is true (src/Renderer/ViewRenderer.php:90, src/Widget/Widget.php:473). Downstream consumers that ask "is the visitor searching?" miss it too, which is why DataTables had to special-case letter for its filtered-count total (GVDT-44 / GVDT-45).

Reproduced test-first: with the widget active, Search_Request::from_arguments( [ 'letter' => 'B' ] ) returned null — not a search.

The fix

The widget now registers its parameter with core, in two layers for version coverage:

  • gk/gravityview/search/request/search-arguments — adds letter so the request counts as a search (feeds is_search(), which also gates entry loading on GravityView 3.0+).
  • gk/gravityview/search/request/filters — strips letter back out of the built filters. It is not a form field, so core must not build a filter for it; gf_query_filter() applies the actual A-Z filtering.
  • gravityview/widget/hide_until_searched (@SInCE 1.5.4) — reveals the View when a letter is active, covering GravityView older than the search-request pipeline.

Tests

Adds the extension's first PHPUnit suite (gkunit harness). Three tests, green on PHP 7.4 and 8.0:

  1. ?letter=B is recognized as a search request (was null before the fix).
  2. letter does not leak into the built field filters (no bogus "letter" field query).
  3. "Hide entries until search" reveals the View when a letter is active.

Note: CI (.circleci) is not yet wired to run the new suite; that's a small follow-up. The suite runs locally via gkunit test.

https://claude.ai/code/session_01CBN4Renmcooc4RxZJpoakU

💾 Build file (3b50fc8).

The widget filters by the `letter` GET parameter and applies its own
gravityview/view/query GF_Query condition, but never told GravityView that
`letter` is a search. So core's is_search() ignored `?letter=`, and a "Hide
entries until search" View stayed hidden when a visitor clicked a letter
(ViewRenderer/Widget gate entry loading on is_search()). Downstream consumers
missed it too (DataTables' filtered-count total, GVDT-44/GVDT-45).

The widget now registers with core:
- gk/gravityview/search/request/search-arguments: adds `letter` so the request
  counts as a search (GravityView 2.55+).
- gk/gravityview/search/request/filters: strips `letter` back out of the built
  filters, since it is not a form field (gf_query_filter applies the filtering).
- gravityview/widget/hide_until_searched (@SInCE 1.5.4): reveals the View when a
  letter is active, covering GravityView older than the search-request pipeline.

Adds the extension's first PHPUnit suite (gkunit): reproduces the miss and
covers all three hooks. Green on PHP 7.4 and 8.0.
@linear-code

linear-code Bot commented Jul 15, 2026

Copy link
Copy Markdown

GVAZ-1

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc8bd7fe-fc4e-45a6-8829-bca84f811162

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/az-search-request

Comment @coderabbitai help to get the list of available commands.

Mwalek added 3 commits July 16, 2026 10:15
…hed Views

Adds the extension's first browser E2E setup (wp-env + Playwright via
@gravitykit/e2e-bootstrap/e2e-fixtures), mounting AZ-Filters, GravityView,
and Gravity Forms. Seeds a Cities form, entries, a List View, and the
az_filter widget through the fixtures REST routes (no editor UI).

Two specs:
- hideUntilSearchedAZReveal: an active ?letter= reveals only the matching
  entries on a hide-until-searched View (fails on the pre-fix widget).
- azFilterNoHideRegression: plain A-Z filtering still returns the correct
  entries per letter on a View without hide-until-searched.
Wires the test suites into CI, mirroring the sibling GravityView-extension
pattern (DataTables): a `prepare` job provisions Gravity Forms and a
GravityView source checkout (git clone + composer install, so its tests/
bootstrap and prefixed Foundation exist), then:
- run_unit_tests: npx @gravitykit/phpunit test --parallel (PHP 7.4 + 8.0)
- run_e2e_tests: boots wp-env and runs the Playwright specs

GravityView + Gravity Forms reach wp-env via WP_ENV_PLUGINS from .env in CI;
locally, wp-env.config.js auto-mounts the sibling repos when present. Release
build gates on the unit tests, matching the sibling repos.

Validated locally: phpunit test --parallel passes on 7.4 and 8.0, the E2E
specs pass, and `circleci config validate` passes.
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.

2 participants