fix(console): RPC command-reference modal audit fixes
- Clicking a command now actually closes the modal. It called ImGui::CloseCurrentPopup(), a no-op here (BeginOverlayDialog is Begin/ BeginChild, not an ImGui popup), so the picker stayed open covering the input and the insert looked like it did nothing. Set show_commands_popup_=false. - Search filter is now a member cleared when the modal opens, so it isn't stale on reopen after an outside-click / command-click dismiss (was reset only by the Close button). - Esc dismisses the modal (this overlay has no built-in Esc handling), and the search box auto-focuses on open so the user can type immediately. - Scale the 2-vs-3 column breakpoint (cmd-min-width) by dpiScale() — it was a logical-px threshold compared against a physical-px available width. - Give each category's table a unique ImGui id (##cmdsN) instead of sharing "##cmds", and translate the 7 category names (Control/Network/... — command descriptions stay English) into all 8 languages; CJK subset rebuilt (+2). (Investigated but rejected: the command-name blue was flagged as low-contrast on light skins, but the modal card is a dark glass panel on every theme, so the original color is correct — verified by rendering marble/light/color-pop-light.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -536,6 +536,7 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec)
|
||||
// Commands reference button (full-node RPC reference only)
|
||||
if (exec.hasRpcReference()) {
|
||||
if (TactileButton(TR("console_commands"), ImVec2(0, 0), schema::UI().resolveFont("button"))) {
|
||||
command_search_[0] = '\0'; // fresh search each open (dismiss paths don't all reset it)
|
||||
show_commands_popup_ = true;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
@@ -1487,6 +1488,20 @@ void drawConsoleCommandParams(const char* params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Translate a command-category name from the static reference tables (English) for display. The
|
||||
// per-command descriptions stay in English (technical RPC docs); only the 7 category labels are i18n'd.
|
||||
const char* consoleCategoryLabel(const char* name)
|
||||
{
|
||||
if (!std::strcmp(name, "Control")) return TR("console_cat_control");
|
||||
if (!std::strcmp(name, "Network")) return TR("console_cat_network");
|
||||
if (!std::strcmp(name, "Blockchain")) return TR("console_cat_blockchain");
|
||||
if (!std::strcmp(name, "Mining")) return TR("console_cat_mining");
|
||||
if (!std::strcmp(name, "Wallet")) return TR("console_cat_wallet");
|
||||
if (!std::strcmp(name, "Raw Transactions")) return TR("console_cat_raw_transactions");
|
||||
if (!std::strcmp(name, "Utility")) return TR("console_cat_utility");
|
||||
return name;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void ConsoleTab::renderCommandsPopup()
|
||||
@@ -1506,16 +1521,19 @@ void ConsoleTab::renderCommandsPopup()
|
||||
if (!material::BeginOverlayDialog(ov)) {
|
||||
return;
|
||||
}
|
||||
// Esc dismisses — this overlay is a plain Begin/BeginChild, not an ImGui popup, so it has no
|
||||
// built-in Esc handling (matches the other editor overlays).
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) show_commands_popup_ = false;
|
||||
|
||||
// Search filter
|
||||
static char cmdFilter[128] = {0};
|
||||
// Search filter — auto-focus on open so the user can type immediately (like the console input).
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
ImGui::InputTextWithHint("##CmdSearch", TR("console_search_commands"), cmdFilter, sizeof(cmdFilter));
|
||||
if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere();
|
||||
ImGui::InputTextWithHint("##CmdSearch", TR("console_search_commands"), command_search_, sizeof(command_search_));
|
||||
ImGui::Dummy(ImVec2(0, Layout::spacingXs()));
|
||||
|
||||
const auto& categories = consoleCommandCategories();
|
||||
|
||||
std::string filter(cmdFilter);
|
||||
std::string filter(command_search_);
|
||||
std::transform(filter.begin(), filter.end(), filter.begin(), ::tolower);
|
||||
|
||||
ImGui::BeginChild("CmdListScroll", ImVec2(0, -ImGui::GetFrameHeightWithSpacing() - Layout::spacingXs()),
|
||||
@@ -1523,7 +1541,10 @@ void ConsoleTab::renderCommandsPopup()
|
||||
|
||||
ImGui::PushFont(Type().caption());
|
||||
|
||||
float cmdMinWidth = schema::UI().drawElement("tabs.console", "cmd-min-width").sizeOr(500.0f);
|
||||
// cmd-min-width is authored in logical px; popupInnerW (GetContentRegionAvail) is physical/DPI-
|
||||
// scaled, so scale the breakpoint to match — otherwise the 2-vs-3 column choice trips at the
|
||||
// wrong width on HiDPI.
|
||||
float cmdMinWidth = schema::UI().drawElement("tabs.console", "cmd-min-width").sizeOr(500.0f) * Layout::dpiScale();
|
||||
float popupInnerW = ImGui::GetContentRegionAvail().x;
|
||||
bool showParams = popupInnerW >= cmdMinWidth;
|
||||
int catIdx = 0;
|
||||
@@ -1550,11 +1571,12 @@ void ConsoleTab::renderCommandsPopup()
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(Primary()));
|
||||
// Show match count badge when filtering
|
||||
const char* catLabel = consoleCategoryLabel(cat.name);
|
||||
char headerLabel[128];
|
||||
if (!filter.empty()) {
|
||||
snprintf(headerLabel, sizeof(headerLabel), "%s (%d)", cat.name, matchCount);
|
||||
snprintf(headerLabel, sizeof(headerLabel), "%s (%d)", catLabel, matchCount);
|
||||
} else {
|
||||
snprintf(headerLabel, sizeof(headerLabel), "%s", cat.name);
|
||||
snprintf(headerLabel, sizeof(headerLabel), "%s", catLabel);
|
||||
}
|
||||
bool open = ImGui::CollapsingHeader(headerLabel, headerFlags);
|
||||
ImGui::PopStyleColor();
|
||||
@@ -1564,7 +1586,9 @@ void ConsoleTab::renderCommandsPopup()
|
||||
float nameColW = schema::UI().drawElement("tabs.console", "cmd-name-col-width").size * Layout::hScale();
|
||||
float paramsColW = schema::UI().drawElement("tabs.console", "cmd-params-col-width").size * Layout::hScale();
|
||||
int numCols = showParams ? 3 : 2;
|
||||
if (ImGui::BeginTable("##cmds", numCols, ImGuiTableFlags_None)) {
|
||||
char tableId[24];
|
||||
snprintf(tableId, sizeof(tableId), "##cmds%d", catIdx); // unique id per category table
|
||||
if (ImGui::BeginTable(tableId, numCols, ImGuiTableFlags_None)) {
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, nameColW);
|
||||
if (showParams)
|
||||
ImGui::TableSetupColumn("Parameters", ImGuiTableColumnFlags_WidthFixed, paramsColW);
|
||||
@@ -1577,6 +1601,8 @@ void ConsoleTab::renderCommandsPopup()
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
// Link-like blue for the command name. Readable on all skins: the RPC-reference
|
||||
// modal card is a dark glass panel regardless of theme, so no light-floor is needed.
|
||||
ImGui::PushStyleColor(ImGuiCol_Text,
|
||||
ImGui::ColorConvertU32ToFloat4(IM_COL32(100, 180, 255, 255)));
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0, 0, 0, 0));
|
||||
@@ -1590,7 +1616,9 @@ void ConsoleTab::renderCommandsPopup()
|
||||
strncpy(input_buffer_, cmd.name, sizeof(input_buffer_) - 1);
|
||||
input_buffer_[sizeof(input_buffer_) - 1] = '\0';
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
// This overlay isn't an ImGui popup, so CloseCurrentPopup() is a no-op here —
|
||||
// close it the way the framework honors, revealing the inserted command.
|
||||
show_commands_popup_ = false;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||
@@ -1621,9 +1649,9 @@ void ConsoleTab::renderCommandsPopup()
|
||||
|
||||
ImGui::Dummy(ImVec2(0, Layout::spacingXs()));
|
||||
|
||||
// Close button
|
||||
// Close button (the filter is also reset when the modal next opens).
|
||||
if (material::TactileButton(TR("console_close"), ImVec2(-1, 0))) {
|
||||
cmdFilter[0] = '\0';
|
||||
command_search_[0] = '\0';
|
||||
show_commands_popup_ = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ private:
|
||||
|
||||
// Commands popup
|
||||
bool show_commands_popup_ = false;
|
||||
char command_search_[128] = {0}; // RPC-reference search filter (cleared when the modal opens)
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
@@ -1294,6 +1294,13 @@ void I18n::loadBuiltinEnglish()
|
||||
strings_["console_toggle_text_color"] = "Toggle line text colors";
|
||||
strings_["console_accents"] = "Color accents";
|
||||
strings_["console_text_colors"] = "Text colors";
|
||||
strings_["console_cat_control"] = "Control";
|
||||
strings_["console_cat_network"] = "Network";
|
||||
strings_["console_cat_blockchain"] = "Blockchain";
|
||||
strings_["console_cat_mining"] = "Mining";
|
||||
strings_["console_cat_wallet"] = "Wallet";
|
||||
strings_["console_cat_raw_transactions"] = "Raw Transactions";
|
||||
strings_["console_cat_utility"] = "Utility";
|
||||
|
||||
// --- Export All Keys Dialog ---
|
||||
strings_["export_keys_btn"] = "Export Keys";
|
||||
|
||||
Reference in New Issue
Block a user