Register the A-Z letter parameter as a search request (GVAZ-1) - #65
Open
zackkatz wants to merge 4 commits into
Open
Register the A-Z letter parameter as a search request (GVAZ-1)#65zackkatz wants to merge 4 commits into
zackkatz wants to merge 4 commits into
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The A-Z Entry Filter widget filters entries by first letter through the
letterGET parameter and its owngravityview/view/queryGF_Query condition, but it never told GravityView thatletteris a search. So core'sis_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-caseletterfor its filtered-count total (GVDT-44 / GVDT-45).Reproduced test-first: with the widget active,
Search_Request::from_arguments( [ 'letter' => 'B' ] )returnednull— 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— addsletterso the request counts as a search (feedsis_search(), which also gates entry loading on GravityView 3.0+).gk/gravityview/search/request/filters— stripsletterback 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:
?letter=Bis recognized as a search request (wasnullbefore the fix).letterdoes not leak into the built field filters (no bogus "letter" field query).https://claude.ai/code/session_01CBN4Renmcooc4RxZJpoakU
💾 Build file (3b50fc8).