Skip to content

Commit

Permalink
fix: Enable submit button after linking items in Drag & Drop Sort Int…
Browse files Browse the repository at this point in the history
…eraction
  • Loading branch information
TanishMoral11 committed Dec 14, 2024
1 parent d321478 commit 499fde0
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ class DragAndDropSortInteractionViewModel private constructor(
dragDropInteractionContentViewModel.itemIndex = index
dragDropInteractionContentViewModel.listSize = _choiceItems.size
}
// to update the content of grouped item

// To update the list
(adapter as BindableAdapter<*>).setDataUnchecked(_choiceItems)

// *Trigger pending answer check* to re-enable submit button
checkPendingAnswerError(AnswerErrorCategory.REAL_TIME)
}

fun unlinkElement(itemIndex: Int, adapter: RecyclerView.Adapter<RecyclerView.ViewHolder>) {
Expand All @@ -246,15 +250,24 @@ class DragAndDropSortInteractionViewModel private constructor(
dragDropInteractionContentViewModel.itemIndex = index
dragDropInteractionContentViewModel.listSize = _choiceItems.size
}
// to update the list

// *Update the list*
(adapter as BindableAdapter<*>).setDataUnchecked(_choiceItems)

// *Trigger pending answer check* to re-enable submit button
checkPendingAnswerError(AnswerErrorCategory.REAL_TIME)
}

private fun getSubmitTimeError(): DragAndDropSortInteractionError {
return if (_originalChoiceItems == _choiceItems) {
val hasItemsChanged = _originalChoiceItems.size != _choiceItems.size ||
_originalChoiceItems.zip(_choiceItems).any { (originalItem, currentItem) ->
originalItem.htmlContent != currentItem.htmlContent
}
return if (!hasItemsChanged) {
DragAndDropSortInteractionError.EMPTY_INPUT
} else
} else {
DragAndDropSortInteractionError.VALID
}
}

/** Implementation of [StateItemViewModel.InteractionItemFactory] for this view model. */
Expand Down

0 comments on commit 499fde0

Please sign in to comment.