feat: Add ref API to Composer for programmatic send box focus#5607
Open
marclundgren wants to merge 2 commits intomicrosoft:mainfrom
Open
feat: Add ref API to Composer for programmatic send box focus#5607marclundgren wants to merge 2 commits intomicrosoft:mainfrom
marclundgren wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
Author
Composer Ref API DocumentationOverviewThe Usage ExamplesTypeScriptimport { useRef } from 'react';
import { Components, ComposerRef } from 'botframework-webchat-component';
const { Composer } = Components;
function MyApp() {
const composerRef = useRef<ComposerRef>(null);
const handleFocusSendBox = async () => {
await composerRef.current?.focusSendBoxInput();
};
return (
<div>
<button onClick={handleFocusSendBox}>Focus Send Box</button>
<Composer
ref={composerRef}
directLine={directLine}
// ... other props
/>
</div>
);
}JavaScriptimport { useRef } from 'react';
import { Components } from 'botframework-webchat-component';
const { Composer } = Components;
function MyApp() {
const composerRef = useRef(null);
const handleFocusSendBox = async () => {
await composerRef.current?.focusSendBoxInput();
};
return (
<div>
<button onClick={handleFocusSendBox}>Focus Send Box</button>
<Composer
ref={composerRef}
directLine={directLine}
// ... other props
/>
</div>
);
}API ReferenceComposerRefThe ref object exposed by the Methods
Implementation Details
|
- Add forwardRef wrapper to Composer component
- Expose focusSendBoxInput() method via ComposerRef
- Export ComposerRef type for TypeScript consumers
- Leverages existing useFocus('sendBox') infrastructure
- Returns Promise for async focus handling
b41436c to
33189fc
Compare
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.
Changelog Entry
Description
Design
Specific Changes
-
CHANGELOG.mdReview Checklist
z-index)package.jsonandpackage-lock.jsonreviewed