-
Notifications
You must be signed in to change notification settings - Fork 434
feat(js)!: expose instance API + lifecycle callbacks #2826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
❌ Deploy Preview for docsearch-demo failed.
|
✅ Deploy Preview for docsearch ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68a2151dd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- openSidepanel() now no-ops if sidepanel view hasn't been registered - Added isSidepanelSupported getter to check before calling - Prevents stuck state when calling openSidepanel() on modal-only instance
|
Could we add an example of this to |
Summary
@docsearch/jsand@docsearch/sidepanel-js(open/close/destroy, plus state getters).@docsearch/core/@docsearch/reactvia forwarded refs +useImperativeHandle.Motivation
Integrations (e.g. VitePress) currently resort to DOM polling to know when DocSearch/Sidepanel are ready and to open them programmatically. This adds a first-class programmatic API.
API changes
@docsearch/jsdocsearch(...)now returns aDocSearchInstancewith:open(),close(),openAskAi(),openSidepanel(),destroy()isReady,isOpen,isSidepanelOpenonReady,onOpen,onClose,onSidepanelOpen,onSidepanelClose@docsearch/sidepanel-jssidepanel(...)now returns aSidepanelInstancewith:open(),close(),openWithMessage(),destroy()isReady,isOpenonReady,onOpen,onCloseBREAKING CHANGE
Yes:
docsearch()andsidepanel()no longer return a bare cleanup function.Migration:
Tests
packages/docsearch-react/src/__tests__/imperative.test.tsx).