added override property to deal with oldvalue/newValue for the selected Item.

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-08-01 10:53:14 -05:00
parent 9606b914cc
commit 3732f98d7c

View File

@ -30,6 +30,19 @@ open class ItemDropdownEntryField: VDS.DropdownSelect, VDSMoleculeViewProtocol,
private var isEditting: Bool = false private var isEditting: Bool = false
//override for to deal with getting the
//old selectedItem to pass down to the observeDropdownChange
open override var selectId: Int? {
didSet {
guard let observeDropdownChange, let selectedItem else { return }
var oldSelectedItem: DropdownOptionModel?
if let oldValue {
oldSelectedItem = options[oldValue]
}
observeDropdownChange(oldSelectedItem?.text, selectedItem.text)
}
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -196,7 +209,6 @@ open class ItemDropdownEntryField: VDS.DropdownSelect, VDSMoleculeViewProtocol,
let pickerIndex = optionsPicker.selectedRow(inComponent: 0) let pickerIndex = optionsPicker.selectedRow(inComponent: 0)
viewModel.selectedIndex = pickerIndex viewModel.selectedIndex = pickerIndex
selectId = pickerIndex selectId = pickerIndex
observeDropdownChange?(selectedItem?.text, pickerData[pickerIndex])
} }
} }