feat(contacts): clear stale selection, state-aware empty/count, disabled-action hint (F001/F042/F023/F043)
UX audit, Contacts surface (batch 1): - F001: a selection hidden by the search or wallet-scope filter is cleared, so a toolbar action (delete/edit/copy) can never act on an off-screen contact. - F042: the empty state now reads from the real state — "No matching contacts" when searching, "No contacts for this wallet yet" when contacts exist only in another wallet's scope, vs. the first-run empty message. - F023: the footer shows "N of M contacts" when a filter/scope hides rows. - F043: the disabled Edit/Delete/Copy buttons show a "Select a contact first" hint. New strings (English). Build + tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1086,6 +1086,8 @@ void RenderContactsTab(App* app)
|
||||
|
||||
if (toolbarBtn("##ab_edit", ICON_MD_EDIT, TR("edit"), false))
|
||||
openEdit();
|
||||
if (!has_selection && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
material::Tooltip("%s", TR("contacts_select_first")); // (F043)
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -1094,11 +1096,15 @@ void RenderContactsTab(App* app)
|
||||
const char* delLabel = armed ? TR("address_book_confirm_delete") : TR("delete");
|
||||
if (toolbarBtn("##ab_del", ICON_MD_DELETE, delLabel, false))
|
||||
doDelete();
|
||||
if (!has_selection && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
material::Tooltip("%s", TR("contacts_select_first")); // (F043)
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (toolbarBtn("##ab_copy", ICON_MD_CONTENT_COPY, TR("copy_address"), false))
|
||||
doCopy();
|
||||
if (!has_selection && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
material::Tooltip("%s", TR("contacts_select_first")); // (F043)
|
||||
|
||||
if (!has_selection) ImGui::EndDisabled();
|
||||
|
||||
@@ -1164,6 +1170,15 @@ void RenderContactsTab(App* app)
|
||||
visibleRows.push_back(i);
|
||||
}
|
||||
|
||||
// Drop a selection the search/scope filter just hid, so a toolbar action (delete, edit, copy) can never
|
||||
// target a contact the user can no longer see. (F001)
|
||||
if (s_selected_index >= 0 &&
|
||||
std::find(visibleRows.begin(), visibleRows.end(),
|
||||
static_cast<size_t>(s_selected_index)) == visibleRows.end()) {
|
||||
s_selected_index = -1;
|
||||
s_confirm_delete_idx = -1;
|
||||
}
|
||||
|
||||
// Address list — fill the tab, leaving room for the count footer.
|
||||
const float footerH = ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().ItemSpacing.y;
|
||||
float listH = ImGui::GetContentRegionAvail().y - footerH;
|
||||
@@ -1316,7 +1331,12 @@ void RenderContactsTab(App* app)
|
||||
ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
material::ApplySmoothScroll(); // wheel-lerp scroll, matching the rest of the app
|
||||
if (visibleRows.empty()) {
|
||||
emptyState(ICON_MD_CONTACTS, book.empty() ? "address_book_empty" : "contacts_search_no_match");
|
||||
// Message from the actual state: searching vs. truly empty vs. contacts exist but all in another
|
||||
// wallet's scope (previously the scope-hidden case wrongly read as "no search match"). (F042)
|
||||
const char* emptyKey = !needle.empty() ? "contacts_search_no_match"
|
||||
: book.empty() ? "address_book_empty"
|
||||
: "contacts_scope_empty";
|
||||
emptyState(ICON_MD_CONTACTS, emptyKey);
|
||||
} else {
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0,0,0,0));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0,0,0,0));
|
||||
@@ -1496,8 +1516,13 @@ void RenderContactsTab(App* app)
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// Status line — singular form for exactly one contact ("1 address saved", not "1 addresses saved").
|
||||
ImGui::TextDisabled(TR(book.size() == 1 ? "address_book_count_one" : "address_book_count"), book.size());
|
||||
// Status line — reflect the search/scope filter ("N of M contacts") when the visible count differs from
|
||||
// the total; otherwise the plain total (singular form for exactly one). (F023)
|
||||
if (visibleRows.size() != book.size()) {
|
||||
ImGui::TextDisabled(TR("contacts_count_filtered"), visibleRows.size(), book.size());
|
||||
} else {
|
||||
ImGui::TextDisabled(TR(book.size() == 1 ? "address_book_count_one" : "address_book_count"), book.size());
|
||||
}
|
||||
|
||||
// Keyboard shortcuts — only when the tab owns focus (no field being edited, no modal up).
|
||||
if (!searchActive && !ImGui::IsAnyItemActive() &&
|
||||
|
||||
@@ -2042,6 +2042,9 @@ void I18n::loadBuiltinEnglish()
|
||||
strings_["contact_global_badge_tt"] = "Global contact — visible in every wallet";
|
||||
strings_["address_book_added"] = "Address added to book";
|
||||
strings_["address_book_count"] = "%zu addresses saved";
|
||||
strings_["contacts_count_filtered"] = "%zu of %zu contacts";
|
||||
strings_["contacts_scope_empty"] = "No contacts for this wallet yet";
|
||||
strings_["contacts_select_first"] = "Select a contact first";
|
||||
strings_["address_book_count_one"] = "%zu address saved";
|
||||
strings_["address_book_deleted"] = "Entry deleted";
|
||||
strings_["address_book_edit"] = "Edit Address";
|
||||
|
||||
Reference in New Issue
Block a user