docs(Autocomplete): add wiring guide, prop cheat sheet, and async source story - #381
Merged
Conversation
…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
Contributor
There was a problem hiding this comment.
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.searchschedules a newsetTimeouton 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.
Deploying ui with
|
| 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 |
…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.
… optional Addresses Copilot review nit on #381.
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.
Summary
The Autocomplete Storybook page previously showed only two bare stories with no guidance on how to feed it data. Consumers installing
@mieweb/uiin 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):import { Autocomplete } from '@mieweb/ui'with the minimal required props (items,getItemKey,renderItem,filter,onSelect)filterpredicatefilter, fetch inonValueChange, re-passitemsoverflow: hidden, full keyboard/ARIA combobox support,minQueryLengthgating, debounce-is-on-you noteAsync Sourcestory — live demo of the server-backed pattern (simulated 400 ms latency, loading state surfaced viaemptyMessage)Verification
pnpm typecheck✅pnpm exec eslint src/components/Autocomplete/Autocomplete.stories.tsx✅pnpm exec prettier --check✅pnpm vitest run src/components/Autocomplete— 7/7 ✅