Merge pull request #223 from cogwheel0/improve-chat-accessibility
feat(chat): Improve accessibility in chat input
This commit is contained in:
@@ -1285,6 +1285,9 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
|
||||
}) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
// Exclude from semantics so screen readers interact directly with the
|
||||
// TextField, which provides its own accessibility via hintText.
|
||||
excludeFromSemantics: true,
|
||||
onTap: () {
|
||||
if (!widget.enabled) return;
|
||||
// Explicit user intent to focus: re-enable autofocus and focus
|
||||
@@ -1293,21 +1296,13 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
|
||||
} catch (_) {}
|
||||
_ensureFocusedIfEnabled();
|
||||
},
|
||||
child: MergeSemantics(
|
||||
child: Semantics(
|
||||
label: AppLocalizations.of(context)!.messageInputLabel,
|
||||
hint: AppLocalizations.of(context)!.messageInputHint,
|
||||
child: Shortcuts(
|
||||
shortcuts: () {
|
||||
final map = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.meta,
|
||||
LogicalKeyboardKey.enter,
|
||||
): const _SendMessageIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.enter,
|
||||
): const _SendMessageIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.enter):
|
||||
const _SendMessageIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.enter):
|
||||
const _SendMessageIntent(),
|
||||
};
|
||||
if (sendOnEnter) {
|
||||
map[LogicalKeySet(LogicalKeyboardKey.enter)] =
|
||||
@@ -1346,8 +1341,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
|
||||
return null;
|
||||
},
|
||||
),
|
||||
_SelectNextPromptIntent:
|
||||
CallbackAction<_SelectNextPromptIntent>(
|
||||
_SelectNextPromptIntent: CallbackAction<_SelectNextPromptIntent>(
|
||||
onInvoke: (intent) {
|
||||
_movePromptSelection(1);
|
||||
return null;
|
||||
@@ -1384,10 +1378,15 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
|
||||
final FontWeight recordingWeight = _isRecording
|
||||
? FontWeight.w500
|
||||
: FontWeight.w400;
|
||||
final TextStyle baseChatStyle =
|
||||
AppTypography.chatMessageStyle;
|
||||
final TextStyle baseChatStyle = AppTypography.chatMessageStyle;
|
||||
|
||||
return TextField(
|
||||
// Wrap with Semantics to provide an accessible label for screen
|
||||
// readers. We avoid MergeSemantics which caused double-
|
||||
// announcements. The TextField provides its own text field
|
||||
// semantics; this just adds the descriptive label.
|
||||
return Semantics(
|
||||
label: AppLocalizations.of(context)!.messageInputLabel,
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
enabled: widget.enabled,
|
||||
@@ -1431,8 +1430,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
|
||||
alignLabelWithHint: true,
|
||||
),
|
||||
// Enable pasting images and files from clipboard
|
||||
contentInsertionConfiguration:
|
||||
ContentInsertionConfiguration(
|
||||
contentInsertionConfiguration: ContentInsertionConfiguration(
|
||||
allowedMimeTypes: ClipboardAttachmentService
|
||||
.supportedImageMimeTypes
|
||||
.toList(),
|
||||
@@ -1447,13 +1445,12 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
|
||||
if (!widget.enabled) return;
|
||||
_ensureFocusedIfEnabled();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user