Skip to content

feat(settings): narrow search results to matching fields - #106

Merged
kzamanbd merged 1 commit into
mainfrom
feat/settings-search-narrow-fields
Nov 26, 2026
Merged

kzamanbd merged 1 commit into
mainfrom
feat/settings-search-narrow-fields

Conversation

@akzmoudud

Copy link
Copy Markdown
Contributor

Changes proposed in this Pull Request

Closes getdokan/dokan-pro#6226

The settings sidebar search only filtered the menu. Opening a matched page showed every field on it, so the setting you searched for was still hard to find. Search now narrows the content too.

Behaviour

  • Matching (settings-search.ts): the query is split into words. A field matches when every word appears in its label, title, description, placeholder, tooltip, options (lists of 8 or fewer), or the labels of the page/subpage/tab/section above it.
  • Content: only matching fields render, plus their containers and any same-page field they depend on. Matching rows get a left bar and a light tint (search-match-style.ts). A results bar offers "Show all settings" (full page, matches still marked) and "Clear search".
  • Counts: the menu and tabs show "N matches". Counts are settings, not fields: a field group or notice that depends on the field just before it (e.g. App ID/Secret under "Connect to Facebook") counts with that field.
  • Hidden matches (search-dependency-hint.tsx): a match hidden by a dependency is replaced by a row saying what reveals it, e.g. "Turn on “Connect to X” above to show this setting."
  • Navigation: 300 ms after typing stops, if the current page has no match, the first page with one opens. It never moves while there are unsaved changes and confirmOnLeave is on. Enter jumps to the first match (with the usual unsaved-changes prompt); Escape clears.
  • Accessibility: sections forced open by a search report aria-expanded="true", tab badges read as ", N matches", and marked rows start with a visually hidden "Search match:".

Behaviour changes for consumers

  • Every consumer of <Settings> gets the new search when it bumps plugin-ui.
  • The auto-jump calls onNavigate like a menu click, so consumers that sync the URL will see it change while searching.
  • Option lists longer than 8 are no longer searched (otherwise words like "withdraw" matched every page selector).

API

  • LayoutMenu: new optional expandAll prop; sub-items now render secondaryLabel.
  • useSettings(): new search members (searchQuery, searchIndex, isSearchVisible, …). Additive only.
  • Settings.mdx: new Search section and selectors (settings-search-results-bar, settings-search-show-all, settings-search-clear, settings-search-empty, settings-tab-count-{id}, settings-search-hidden-{id}, settings-search-hidden-group-{id}, [data-settings-search-match]).

Follow-ups (not in this PR)

  • The index is rebuilt on every keystroke; the query-independent part could be memoized on the schema.
  • expandAll doesn't reach nested subpage groups in LayoutMenu.
  • "Showing 1 of N" doesn't count the controlling field kept visible next to a match.

How to test

  1. Use this build in Dokan Lite (admin → Dokan → Settings).
  2. Search "facebook": only Vendors › Social Onboarding stays in the menu, the page shows only the Facebook setting, and the count is per setting.
  3. Search "day of week": Transaction › Withdraw opens with a row explaining which switch reveals "Day of Week". "Show all settings" keeps that row marked and scrolls to it.
  4. Change a field without saving, then search for something on another page: the page doesn't change and the results bar asks you to save first.
  5. npm run typecheck, npm run lint, npx wp-scripts test-unit-js (new settings-search.test.ts, 11 tests).

🤖 Generated with Claude Code

The sidebar search only filtered the menu, so opening a matched page
showed every field on it. Search now narrows the content to matching
settings, shows per-page and per-tab match counts, opens the first page
with a match, and explains matches hidden by a dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@akzmoudud akzmoudud self-assigned this Nov 25, 2026
@kzamanbd
kzamanbd merged commit 89c4d58 into main Nov 26, 2026
1 check passed
@kzamanbd
kzamanbd deleted the feat/settings-search-narrow-fields branch November 26, 2026 06:24
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