-
Notifications
You must be signed in to change notification settings - Fork 72
Reverted the semantic value from textfield #708
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,91 +167,86 @@ class _TextBoxControlState extends State<TextBoxControl> | |
| controllerMap.putIfAbsent(lang, | ||
| () => TextEditingController(text: _getDataFromMap(lang))); | ||
| }); | ||
| return Semantics( | ||
| label: '${widget.e.id}', | ||
| container: true, | ||
| excludeSemantics: true, | ||
| child: Container( | ||
| margin: const EdgeInsets.only(bottom: 8), | ||
| child: TextFormField( | ||
| autovalidateMode: AutovalidateMode.onUserInteraction, | ||
| controller: controllerMap[lang], | ||
| textCapitalization: TextCapitalization.words, | ||
| onChanged: (value) async { | ||
| if (lang == mandatoryLanguageCode) { | ||
| for (var target in choosenLang) { | ||
| String targetCode = globalProvider.langToCode(target); | ||
| if (targetCode != mandatoryLanguageCode) { | ||
| log("$mandatoryLanguageCode ----> $targetCode"); | ||
| try { | ||
| String result = await TransliterationServiceImpl() | ||
| .transliterate(TransliterationOptions( | ||
| input: value, | ||
| sourceLanguage: "Any", | ||
| targetLanguage: tranliterationLangMapper[ | ||
| targetCode] ?? | ||
| targetCode.substring(0, 2))); | ||
| _saveDataToMap(result, targetCode); | ||
| saveData(result, targetCode); | ||
| setState(() { | ||
| controllerMap[targetCode]!.text = result; | ||
| }); | ||
| log("Transliteration success : $result"); | ||
| } catch (e) { | ||
| log("Transliteration failed : $e"); | ||
| } | ||
| return Container( | ||
| margin: const EdgeInsets.only(bottom: 8), | ||
| child: TextFormField( | ||
| autovalidateMode: AutovalidateMode.onUserInteraction, | ||
| controller: controllerMap[lang], | ||
| textCapitalization: TextCapitalization.words, | ||
| onChanged: (value) async { | ||
| if (lang == mandatoryLanguageCode) { | ||
| for (var target in choosenLang) { | ||
| String targetCode = globalProvider.langToCode(target); | ||
| if (targetCode != mandatoryLanguageCode) { | ||
| log("$mandatoryLanguageCode ----> $targetCode"); | ||
| try { | ||
| String result = await TransliterationServiceImpl() | ||
| .transliterate(TransliterationOptions( | ||
| input: value, | ||
| sourceLanguage: "Any", | ||
| targetLanguage: tranliterationLangMapper[ | ||
| targetCode] ?? | ||
| targetCode.substring(0, 2))); | ||
| _saveDataToMap(result, targetCode); | ||
| saveData(result, targetCode); | ||
| setState(() { | ||
| controllerMap[targetCode]!.text = result; | ||
| }); | ||
| log("Transliteration success : $result"); | ||
| } catch (e) { | ||
| log("Transliteration failed : $e"); | ||
| } | ||
| } | ||
| } | ||
| _saveDataToMap(value, lang); | ||
| saveData(value, lang); | ||
| }, | ||
| validator: (value) { | ||
| if (!widget.e.required!) { | ||
| if (widget.e.requiredOn == null || | ||
| widget.e.requiredOn!.isEmpty || | ||
| !(globalProvider.mvelRequiredFields[widget.e.id] ?? | ||
| true)) { | ||
| if (value == null || value.isEmpty) { | ||
| return null; | ||
| } else if (!widget.validation.hasMatch(value)) { | ||
| return AppLocalizations.of(context)!.invalid_input; | ||
| } | ||
| } | ||
| _saveDataToMap(value, lang); | ||
| saveData(value, lang); | ||
| }, | ||
|
Comment on lines
+176
to
+204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore stale transliteration responses. Each keystroke starts async transliteration work and then blindly writes the awaited result into the target controllers. If an older request finishes last, it can overwrite newer input and persist stale demographics. Possible fix class _TextBoxControlState extends State<TextBoxControl>
with WidgetsBindingObserver {
bool isMvelValid = true;
Map<String, TextEditingController> controllerMap = {};
late GlobalProvider globalProvider;
late RegistrationTaskProvider registrationTaskProvider;
+ int _transliterationRequestId = 0;
@@
onChanged: (value) async {
+ final requestId = ++_transliterationRequestId;
if (lang == mandatoryLanguageCode) {
for (var target in choosenLang) {
String targetCode = globalProvider.langToCode(target);
if (targetCode != mandatoryLanguageCode) {
@@
String result = await TransliterationServiceImpl()
.transliterate(TransliterationOptions(
input: value,
sourceLanguage: "Any",
targetLanguage: tranliterationLangMapper[
targetCode] ??
targetCode.substring(0, 2)));
+ if (!mounted ||
+ requestId != _transliterationRequestId ||
+ controllerMap[lang]?.text != value) {
+ continue;
+ }
_saveDataToMap(result, targetCode);
saveData(result, targetCode);
setState(() {
controllerMap[targetCode]!.text = result;
});🤖 Prompt for AI Agents |
||
| validator: (value) { | ||
| if (!widget.e.required!) { | ||
| if (widget.e.requiredOn == null || | ||
| widget.e.requiredOn!.isEmpty || | ||
| !(globalProvider.mvelRequiredFields[widget.e.id] ?? | ||
| true)) { | ||
| if (value == null || value.isEmpty) { | ||
| return null; | ||
| } else if (!widget.validation.hasMatch(value)) { | ||
| return AppLocalizations.of(context)!.invalid_input; | ||
| } | ||
| } | ||
| // if (!widget.e.required! && | ||
| // (widget.e.requiredOn == null || | ||
| // widget.e.requiredOn!.isEmpty)) { | ||
| // if (value == null || value.isEmpty) { | ||
| // return null; | ||
| // } else if (!widget.validation.hasMatch(value)) { | ||
| // return AppLocalizations.of(context)!.invalid_input; | ||
| // } | ||
| // } | ||
| if (value == null || value.isEmpty) { | ||
| return AppLocalizations.of(context)! | ||
| .enter_value_message; | ||
| } | ||
| if (!widget.validation.hasMatch(value)) { | ||
| return AppLocalizations.of(context)!.invalid_input; | ||
| } | ||
| return null; | ||
| }, | ||
| textAlign: Bidi.isRtlLanguage(lang.substring(0, 2)) | ||
| ? TextAlign.right | ||
| : TextAlign.left, | ||
| decoration: InputDecoration( | ||
| border: OutlineInputBorder( | ||
| borderRadius: BorderRadius.circular(8.0), | ||
| borderSide: | ||
| const BorderSide(color: appGreyShade, width: 1), | ||
| ), | ||
| contentPadding: const EdgeInsets.symmetric( | ||
| vertical: 14, horizontal: 16), | ||
| hintText: widget.e.label![lang], | ||
| hintStyle: | ||
| const TextStyle(color: appBlackShade3, fontSize: 14), | ||
| } | ||
| // if (!widget.e.required! && | ||
| // (widget.e.requiredOn == null || | ||
| // widget.e.requiredOn!.isEmpty)) { | ||
| // if (value == null || value.isEmpty) { | ||
| // return null; | ||
| // } else if (!widget.validation.hasMatch(value)) { | ||
| // return AppLocalizations.of(context)!.invalid_input; | ||
| // } | ||
| // } | ||
| if (value == null || value.isEmpty) { | ||
| return AppLocalizations.of(context)! | ||
| .enter_value_message; | ||
| } | ||
| if (!widget.validation.hasMatch(value)) { | ||
| return AppLocalizations.of(context)!.invalid_input; | ||
| } | ||
| return null; | ||
| }, | ||
| textAlign: Bidi.isRtlLanguage(lang.substring(0, 2)) | ||
| ? TextAlign.right | ||
| : TextAlign.left, | ||
| decoration: InputDecoration( | ||
| border: OutlineInputBorder( | ||
| borderRadius: BorderRadius.circular(8.0), | ||
| borderSide: | ||
| const BorderSide(color: appGreyShade, width: 1), | ||
| ), | ||
| contentPadding: const EdgeInsets.symmetric( | ||
| vertical: 14, horizontal: 16), | ||
| hintText: widget.e.label![lang], | ||
| hintStyle: | ||
| const TextStyle(color: appBlackShade3, fontSize: 14), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
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.
Make the field validator match the fetch-time rules.
This validator only rejects values longer than
pridLength. Short or non-numeric IDs still passvalidate(), so the fetch handler proceeds into the invalid-ID branch and its side effects. Mirror the exact-length + digits check here.Possible fix
validator: (value) { if (value == null || value.isEmpty) return null; - if (globalProvider.pridLength != null && - value.length > globalProvider.pridLength!) { - return AppLocalizations.of(context)! - .prid_length_greater(globalProvider.pridLength!); + final pridLength = globalProvider.pridLength; + if (pridLength != null && + (value.length != pridLength || + !RegExp(r'^\d+$').hasMatch(value))) { + return AppLocalizations.of(context)!.correct_application_id; } return null; },🤖 Prompt for AI Agents