End continuous mode when clicking text field

pull/5167/head
hunteraraujo 2023-09-06 12:10:57 -07:00
parent 2e62c517e2
commit 27e9868aa5
1 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,22 @@ class _ChatInputFieldState extends State<ChatInputField> {
final TextEditingController _controller = TextEditingController();
final FocusNode _focusNode = FocusNode();
@override
void initState() {
super.initState();
_focusNode.addListener(() {
if (_focusNode.hasFocus && widget.isContinuousMode) {
widget.onContinuousModePressed();
}
});
}
@override
void dispose() {
_focusNode.dispose(); // Dispose of the FocusNode when you're done.
super.dispose();
}
@override
Widget build(BuildContext context) {
// Using LayoutBuilder to provide the current constraints of the widget,
@ -54,7 +70,6 @@ class _ChatInputFieldState extends State<ChatInputField> {
// when the content exceeds its maximum height
child: SingleChildScrollView(
reverse: true,
// TODO: Include tool tip to explain clicking text field will end continuous mode
child: TextField(
controller: _controller,
focusNode: _focusNode,