Skip to content

docs(Autocomplete): add wiring guide, prop cheat sheet, and async source story - #381

Merged
garrity-miepub merged 3 commits into
mainfrom
docs/autocomplete-wiring
Aug 19, 2026
Merged

docs(Autocomplete): add wiring guide, prop cheat sheet, and async source story#381
garrity-miepub merged 3 commits into
mainfrom
docs/autocomplete-wiring

Conversation

@garrity-miepub

Copy link
Copy Markdown
Collaborator

Summary

The Autocomplete Storybook page previously showed only two bare stories with no guidance on how to feed it data. Consumers installing @mieweb/ui in another app had no self-serve reference for wiring up their own data source. This PR turns the docs page into a complete setup guide.

What changed

Docs-only change to src/components/Autocomplete/Autocomplete.stories.tsx (+153, no component code touched):

  • Quick start — copy-paste snippet: import { Autocomplete } from '@mieweb/ui' with the minimal required props (items, getItemKey, renderItem, filter, onSelect)
  • The two wiring patterns — explicit recipes with code for:
    1. Local filtering — pass all items + a filter predicate
    2. Remote / async — omit filter, fetch in onValueChange, re-pass items
  • Prop cheat sheet — table grouping every prop by concern (data in, filtering, selection out, query control, create-new row, popover behavior, styling)
  • Good to know — portal + fixed positioning escapes overflow: hidden, full keyboard/ARIA combobox support, minQueryLength gating, debounce-is-on-you note
  • New Async Source story — live demo of the server-backed pattern (simulated 400 ms latency, loading state surfaced via emptyMessage)
  • Per-story descriptions added to Basic and Creatable

Verification

  • pnpm typecheck
  • pnpm exec eslint src/components/Autocomplete/Autocomplete.stories.tsx
  • pnpm exec prettier --check
  • pnpm vitest run src/components/Autocomplete — 7/7 ✅
  • Verified live in Storybook: all doc sections render; Async Source story fetches and selects correctly ("sar" → Sarah Johnson)

…rce story

- Component docs now explain the two data-wiring patterns (local
  filtering vs remote/async fetch) with copy-paste examples
- Quick start snippet and prop cheat sheet grouped by concern
- New Async Source story demonstrating server-backed lookups with
  loading state via emptyMessage
- Story descriptions for Basic and Creatable
Copilot AI lite review requested due to automatic review settings August 19, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Storybook documentation for Autocomplete by turning the stories file into a full wiring guide for consumers, including quick-start usage, common data-source patterns, and a new async-backed demo story.

Changes:

  • Added a component-level docs guide covering quick start, local vs remote wiring patterns, and “good to know” behavior notes.
  • Added a prop “cheat sheet” table grouping props by concern.
  • Added per-story docs descriptions for Basic, Creatable, and introduced a new Async Source story demonstrating server-backed usage.
Suppressed comments (1)

src/components/Autocomplete/Autocomplete.stories.tsx:242

  • AsyncExample.search schedules a new setTimeout on every keystroke without cancelling the previous one. Typing quickly can cause out-of-order updates (older timeouts overwriting newer results) and can also trigger state updates after unmount. Consider tracking the pending timeout (e.g., useRef) and clearing it on each new query and on unmount.
    setLoading(true);
    setTimeout(() => {
      setItems(
        employees.filter((e) => e.name.toLowerCase().includes(q.toLowerCase()))
      );

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/Autocomplete/Autocomplete.stories.tsx
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: e83e136
Status: ✅  Deploy successful!
Preview URL: https://e9635a39.ui-6d0.pages.dev
Branch Preview URL: https://docs-autocomplete-wiring.ui-6d0.pages.dev

View logs

…ry change

Clearing the query mid-request left loading stuck true and let the
stale timeout repopulate items. Track the pending timeout in a ref
and cancel per keystroke. Addresses Copilot review on #381.
Copilot AI review requested due to automatic review settings August 19, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/components/Autocomplete/Autocomplete.stories.tsx Outdated
Copilot AI review requested due to automatic review settings August 19, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@garrity-miepub
garrity-miepub merged commit f191875 into main Aug 19, 2026
16 of 17 checks passed
@garrity-miepub
garrity-miepub deleted the docs/autocomplete-wiring branch August 19, 2026 20:50
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