fix(loyalty): clear staff_id when autocomplete selection is removed
When a staff member was selected and then the name field was edited or cleared, the staff_id (email) remained set. Now tracks the selected member name and clears staff_id when the search text diverges. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,9 @@ function loyaltyPinsList(config) {
|
||||
staffSearch: '',
|
||||
showStaffDropdown: false,
|
||||
|
||||
// Track which member was selected (to detect when user edits away)
|
||||
_selectedStaffName: '',
|
||||
|
||||
get filteredStaff() {
|
||||
if (!this.staffSearch) return this.staffMembers;
|
||||
const q = this.staffSearch.toLowerCase();
|
||||
@@ -75,13 +78,24 @@ function loyaltyPinsList(config) {
|
||||
this.pinForm.name = member.full_name;
|
||||
this.pinForm.staff_id = member.email;
|
||||
this.staffSearch = member.full_name;
|
||||
this._selectedStaffName = member.full_name;
|
||||
this.showStaffDropdown = false;
|
||||
},
|
||||
|
||||
onStaffSearchInput() {
|
||||
this.pinForm.name = this.staffSearch;
|
||||
// If user modified the text away from the selected member, clear staff_id
|
||||
if (this._selectedStaffName && this.staffSearch !== this._selectedStaffName) {
|
||||
this.pinForm.staff_id = '';
|
||||
this._selectedStaffName = '';
|
||||
}
|
||||
},
|
||||
|
||||
clearStaffSelection() {
|
||||
this.staffSearch = '';
|
||||
this.pinForm.name = '';
|
||||
this.pinForm.staff_id = '';
|
||||
this._selectedStaffName = '';
|
||||
this.showStaffDropdown = false;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user