Skip to content

Commit

Permalink
Merge pull request #216 from humhub/209-remove-spaces-in-the-opener-u…
Browse files Browse the repository at this point in the history
…rl-field

Trim spaces on change
  • Loading branch information
luke- authored Aug 5, 2024
2 parents 0c07900 + 6c47417 commit 55c3685
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/pages/opener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ class OpenerState extends ConsumerState<Opener> with SingleTickerProviderStateMi
controlLer.helper.onSaved(controlLer.formUrlKey);
_connectInstance();
},
onChanged: (value) {
// Calculate the new cursor position
final cursorPosition = controlLer.urlTextController.selection.baseOffset;
final trimmedValue = value.trim();
// Update the text controller and set the new cursor position
controlLer.urlTextController.value = TextEditingValue(
text: trimmedValue,
selection: TextSelection.collapsed(offset: cursorPosition > trimmedValue.length ? trimmedValue.length : cursorPosition),
);
},
style: const TextStyle(
decoration: TextDecoration.none,
),
Expand Down

0 comments on commit 55c3685

Please sign in to comment.