Skip to content

Commit

Permalink
fix: Prevent deck creation on 'Enter' key when deck name already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Giyutomioka-SS committed Oct 1, 2024
1 parent 11e1a60 commit 565cc2e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ class CreateDeckDialog(
val inputField = dialog.getInputField()
inputField.setOnEditorActionListener { _, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_DONE || event?.keyCode == KeyEvent.KEYCODE_ENTER) {
onPositiveButtonClicked()
// Check if the positive button is enabled
if (dialog.positiveButton.isEnabled) {
onPositiveButtonClicked()
} else {
Snackbar.make(dialog.getInputTextLayout(), context.getString(R.string.deck_already_exists), Snackbar.LENGTH_LONG).show()
}
true
} else {
false
Expand Down

0 comments on commit 565cc2e

Please sign in to comment.