Angular playground

Nova v3.37.0

Preview

Angular

nv-fielddropdown guide

Choosing between strict and smart filtering for long lists.

← nv-fielddropdown

Nova Dropdown Filtering Modes

This document explains Nova's tiered filtering strategy for dropdown-like components to deliver a "smart" UX while preserving performance on large datasets and low-end devices.

Supported Components

  • nv-fielddropdown
  • nv-fieldmultiselect

Goals

  • Provide a forgiving user experience:
    • Multi-word input should match regardless of word order
    • Optional typo tolerance (fuzzy)
  • Guarantee responsiveness:
    • Avoid main-thread blocking on large datasets
    • Protect DOM rendering with a hard maxResults cap
  • Provide predictable configuration:
    • filterMode controls intent (strict vs smart vs fuzzy)
    • Worker offloading controlled by filterMode and workerThreshold

Quick Decision Guide

Use strict when…

  • Users search by IDs, codes, references
  • You want deterministic substring behavior
  • Examples: INV-2025-00031, A-1024, SKU-RED-XL

Use smart when…

  • Users search by human-readable labels
  • Multi-word input is common
  • You want a "smart" feel without fuzzy costs

Use fuzzy when…

  • Typos are common and you want tolerance
  • Dataset is text-heavy (names, labels)
  • You accept the cost of worker-based fuzzy indexing/search

Props / Configuration

filter-mode

Type: 'strict' | 'smart' | 'fuzzy'
Default: 'strict'

  • strict: normalized substring includes
  • smart: token-based (ALL tokens must match), ignores word order
  • fuzzy: typo tolerant, runs in a Web Worker

Fallback: If Web Workers are not available, fuzzy degrades to smart.


max-results

Type: number
Default: 200
Hard cap: 500

Rationale: Rendering thousands of DOM nodes is often the main bottleneck, even if filtering is fast. maxResults protects the UI by limiting what gets rendered.

When results exceed maxResults, an informational non-selectable row is shown:

"200 results shown out of 3,482 — refine your search"

The truncation message can be customized with the truncated-results-text prop.


worker-threshold

Type: number
Default: 2000

If items.length > workerThreshold, filtering is offloaded to a Web Worker to keep the main thread responsive.
Additionally, filterMode='fuzzy' always requires a Worker.


fuzzy-threshold

Type: number
Default: 0.3

Controls fuzzy strictness (Fuse.js threshold semantics):

  • Lower = stricter (fewer results, more relevant)
  • Higher = more permissive (risk of irrelevant matches)

start-filter-at

Type: number
Default: 0

Minimum number of characters the user must type before filtering begins. Useful for very large datasets to avoid overwhelming initial results.


Debounce

  • Default debounce (strict / smart): Uses debounce-delay prop (default 300ms)
  • Fuzzy debounce: Always 300ms

Mode Details

1) Strict Mode

Behavior

Strict mode uses a normalized includes() check:

  • Case-insensitive
  • Accent-insensitive
  • Substring-based; word order matters

Example

Item label: "System Grid Control"

  • Query: "Grid Sys" ❌ (substring is not contiguous)
  • Query: "System Grid" ✅
  • Query: "Grid System" ❌ (wrong order)

Recommended Use Cases

  • IDs, codes, SKUs
  • When predictable substring behavior is required

2) Smart Mode (Token-based, ALL tokens)

Behavior

Smart mode:

  1. Normalizes input and labels (case/accents/punctuation).
  2. Splits the query into tokens by spaces.
  3. Matches only if ALL tokens exist in the target label (order ignored).

This solves word-order problems without the cost of fuzzy search.

Examples

Item label: "System Grid Control"

  • Query: "System Grid" ✅ tokens: ["system","grid"]
  • Query: "Grid Sys" ✅ tokens: ["grid","sys"] (both exist as substrings)
  • Query: "Control System" ✅
  • Query: "System Unknown" ❌

Why it's fast

  • Labels are indexed once (normalized + tokenized).
  • Search is a linear scan with cheap checks.

Recommended Use Cases

  • Default for human labels
  • Multi-word queries (order independent)
  • Large datasets where fuzzy is too costly

3) Fuzzy Mode (Fuse.js in Web Worker)

Behavior

Fuzzy mode provides typo tolerance via a Bitap-based fuzzy engine (Fuse.js).
It must run inside a Web Worker to avoid blocking the UI.

Examples

Item label: "System Grid Control"

  • Query: "Sytem" ✅ matches "System"
  • Query: "Gird" ✅ matches "Grid" (depending on threshold)
  • Query: "Systm Grid" ✅ likely matches

Worker Requirements

Fuzzy mode always runs in a Web Worker:

  • Worker is initialized (indexed) when items change
  • Searches are executed asynchronously
  • UI stays responsive while waiting for results

Loading UX (never blank)

While waiting for Worker results:

  • Keep the previous list visible
  • Show a subtle loading indicator
  • Do not display an empty list unless the worker confirms no results

Fallback

If Web Workers are not available:

  • filterMode='fuzzy' degrades to smart

Large Datasets & Performance Notes

DOM is often the bottleneck

Even with fast filtering, rendering thousands of items can freeze low-end devices. maxResults protects the UI.

Offloading rule

Filtering must run in Worker when:

  • filterMode === 'fuzzy', OR
  • items.length > workerThreshold

Usage Examples

nv-fielddropdown — strict

html<nv-fielddropdown
  filterable
  filter-mode="strict"
  max-results="200"
></nv-fielddropdown>

nv-fielddropdown — smart (recommended)

html<nv-fielddropdown
  filterable
  filter-mode="smart"
  max-results="200"
></nv-fielddropdown>

nv-fielddropdown — fuzzy

html<nv-fielddropdown
  filterable
  filter-mode="fuzzy"
  fuzzy-threshold="0.3"
  worker-threshold="2000"
  max-results="200"
></nv-fielddropdown>

nv-fieldmultiselect — smart

html<nv-fieldmultiselect
  filterable
  filter-mode="smart"
  max-results="100"
></nv-fieldmultiselect>

Dev Playground

A live playground is available in the development environment:

Location: packages/native/dev/components/dev-dropdown-filtering.tsx

Route: /components/dropdown-filtering

It allows you to:

  • Switch filterMode (strict/smart/fuzzy)
  • Test datasets: 100 / 2,000 / 10,000 / 30,000 items
  • Tweak: workerThreshold, maxResults, fuzzyThreshold, startFilterAt
  • View stats: total results, truncated, last search time (ms), usingWorker

Built-in test queries:

  • "System Grid" - matches in all modes
  • "Grid Sys" - matches in smart/fuzzy, fails in strict
  • "Sytem" (typo) - only matches in fuzzy mode

Architecture

The filtering logic is implemented in a shared module:

plaintextpackages/native/src/utils/search-engine/
├── index.ts                    # Public exports
├── types.ts                    # TypeScript interfaces
├── normalize.ts                # Text normalization (case, accents, punctuation)
├── guards.ts                   # Value clamping (maxResults, thresholds)
├── indexer.ts                  # Pre-computes search index
├── engine.ts                   # Main search orchestration
├── strategies/
│   ├── strict.ts              # Substring matching
│   └── smart.ts               # Token-based matching
└── worker/
    ├── search.worker.ts       # Web Worker for fuzzy/large datasets
    └── worker-client.ts       # Worker communication client

Key Features

  • Pre-computed index: Labels are normalized and tokenized once when data changes
  • Worker offloading: Heavy operations run in Web Worker to keep UI responsive
  • Graceful fallback: Fuzzy degrades to smart if Workers aren't available
  • Hard limits: maxResults capped at 500 to protect DOM performance