Skip to content

Commit ec76989

Browse files
authored
Merge pull request #3 from boursorama/bugfix/AA2K25-243-etape-signature-otp
fix(a11y): rendre le TextFormField cliquable pour l'accessibilité
2 parents 60fe789 + a9c8759 commit ec76989

1 file changed

Lines changed: 56 additions & 50 deletions

File tree

lib/src/pin_code_fields.dart

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -779,55 +779,57 @@ class _PinCodeTextFieldState extends State<PinCodeTextField>
779779
textDirection: widget.errorTextDirection,
780780
child: Padding(
781781
padding: widget.errorTextMargin,
782-
child: TextFormField(
783-
textInputAction: widget.textInputAction,
784-
controller: _textEditingController,
785-
focusNode: _focusNode,
786-
enabled: widget.enabled,
787-
autofillHints: widget.enablePinAutofill && widget.enabled
788-
? <String>[AutofillHints.oneTimeCode]
789-
: null,
790-
autofocus: widget.autoFocus,
791-
autocorrect: false,
792-
keyboardType: widget.keyboardType,
793-
keyboardAppearance: widget.keyboardAppearance,
794-
textCapitalization: widget.textCapitalization,
795-
validator: widget.validator,
796-
onSaved: widget.onSaved,
797-
autovalidateMode: widget.autovalidateMode,
798-
inputFormatters: [
799-
...widget.inputFormatters,
800-
LengthLimitingTextInputFormatter(
801-
widget.length,
802-
), // this limits the input length
803-
],
804-
// trigger on the complete event handler from the keyboard
805-
onFieldSubmitted: widget.onSubmitted,
806-
onEditingComplete: widget.onEditingComplete,
807-
enableInteractiveSelection: false,
808-
showCursor: false,
809-
// using same as background color so tha it can blend into the view
810-
cursorWidth: 0.01,
811-
decoration: InputDecoration(
812-
contentPadding: const EdgeInsets.all(0),
813-
border: InputBorder.none,
814-
fillColor: widget.backgroundColor,
815-
enabledBorder: InputBorder.none,
816-
focusedBorder: InputBorder.none,
817-
disabledBorder: InputBorder.none,
818-
errorBorder: InputBorder.none,
819-
focusedErrorBorder: InputBorder.none,
820-
),
821-
style: TextStyle(
822-
color: Colors.transparent,
823-
height: .01,
824-
fontSize: kIsWeb
825-
? 1
826-
: 0.01, // it is a hidden textfield which should remain transparent and extremely small
782+
child: ExcludeSemantics(
783+
child: TextFormField(
784+
textInputAction: widget.textInputAction,
785+
controller: _textEditingController,
786+
focusNode: _focusNode,
787+
enabled: widget.enabled,
788+
autofillHints: widget.enablePinAutofill && widget.enabled
789+
? <String>[AutofillHints.oneTimeCode]
790+
: null,
791+
autofocus: widget.autoFocus,
792+
autocorrect: false,
793+
keyboardType: widget.keyboardType,
794+
keyboardAppearance: widget.keyboardAppearance,
795+
textCapitalization: widget.textCapitalization,
796+
validator: widget.validator,
797+
onSaved: widget.onSaved,
798+
autovalidateMode: widget.autovalidateMode,
799+
inputFormatters: [
800+
...widget.inputFormatters,
801+
LengthLimitingTextInputFormatter(
802+
widget.length,
803+
), // this limits the input length
804+
],
805+
// trigger on the complete event handler from the keyboard
806+
onFieldSubmitted: widget.onSubmitted,
807+
onEditingComplete: widget.onEditingComplete,
808+
enableInteractiveSelection: false,
809+
showCursor: false,
810+
// using same as background color so tha it can blend into the view
811+
cursorWidth: 0.01,
812+
decoration: InputDecoration(
813+
contentPadding: const EdgeInsets.all(0),
814+
border: InputBorder.none,
815+
fillColor: widget.backgroundColor,
816+
enabledBorder: InputBorder.none,
817+
focusedBorder: InputBorder.none,
818+
disabledBorder: InputBorder.none,
819+
errorBorder: InputBorder.none,
820+
focusedErrorBorder: InputBorder.none,
821+
),
822+
style: TextStyle(
823+
color: Colors.transparent,
824+
height: .01,
825+
fontSize: kIsWeb
826+
? 1
827+
: 0.01, // it is a hidden textfield which should remain transparent and extremely small
828+
),
829+
scrollPadding: widget.scrollPadding,
830+
readOnly: widget.readOnly,
831+
obscureText: widget.obscureText,
827832
),
828-
scrollPadding: widget.scrollPadding,
829-
readOnly: widget.readOnly,
830-
obscureText: widget.obscureText,
831833
),
832834
),
833835
);
@@ -845,8 +847,12 @@ class _PinCodeTextFieldState extends State<PinCodeTextField>
845847
alignment: Alignment.bottomCenter,
846848
children: <Widget>[
847849
AbsorbPointer(
848-
// this is a hidden textfield under the pin code fields.
849-
absorbing: true, // it prevents on tap on the text field
850+
// This is a hidden textfield under the pin code fields.
851+
// The `absorbing` property determines whether the text field absorbs touch events or not.
852+
// By adding the MediaQuery condition, we ensure that the text field is only tappable
853+
// when accessibility features (like screen readers or accessible navigation) are enabled.
854+
// This improves accessibility for users who rely on such features.
855+
absorbing: !MediaQuery.of(context).accessibleNavigation,
850856
child: widget.useExternalAutoFillGroup
851857
? textField
852858
: AutofillGroup(

0 commit comments

Comments
 (0)