Fix: search redirecting early and missing full tank names

**Enter key**
- Enter redirected to the previous results' first tank while a search was still buffering, because the key handler captured a stale `searching` value.
- Enter on an empty field redirected to the first tank of the unfiltered list (Sheridan).
- The handler now reads live filter state and only acts when there is a settled search, matching the quick-link button.

**Full names in search**
- Search only knew short tank names, so queries like "super pershing" found nothing when the game stores a short form.
- Add an optional `name_full` to `TankDefinition`, filled from the game's full name when a short name exists, and index it (plus an accent-stripped copy) in `fetchTankNames` / `SEARCH_KEYS`.
- Displayed names are unchanged. Full names become searchable once the definitions are regenerated on the next build.
This commit is contained in:
Mark Greene committed 2026-10-04 14:24:02 +13:00
1 parent f3e8cdd5e0
commit 6153beced6
5 files changed
+39 -1

No files matched your search

@@ -371,6 +371,9 @@ export abstract class ServerBlitzKitAPI1 extends ServerBlitzKitAPI0 {
(tank.shortUserString
? this.getString(tank.shortUserString)
: undefined) ?? this.getString(tank.userString),
name_full: tank.shortUserString
? this.getString(tank.userString)
: undefined,
slug,
nation,
type: tankTags.includes("collectible")
+13
View File
@@ -18,11 +18,22 @@ export async function fetchTankNames(api: BlitzKitAPI) {
searchableNameDeburr.locales[key] = deburr(value);
});
const searchableNameFull: I18nString = {
locales: { ...tank.name_full?.locales },
};
const searchableNameFullDeburr: I18nString = { locales: {} };
Object.entries(searchableNameFull.locales).forEach(([key, value]) => {
searchableNameFullDeburr.locales[key] = deburr(value);
});
return {
id: tank.id,
name: tank.name,
searchableName: tank.name,
searchableNameDeburr,
searchableNameFull,
searchableNameFullDeburr,
camouflages: tank.camouflages
?.map((id) =>
locales.supported.map(
@@ -45,6 +56,8 @@ export const SEARCH_KEYS = [
.map(({ locale }) => [
`searchableName.locales.${locale}`,
`searchableNameDeburr.locales.${locale}`,
`searchableNameFull.locales.${locale}`,
`searchableNameFullDeburr.locales.${locale}`,
])
.flat(),
"camouflages",
@@ -41,6 +41,7 @@ message TankDefinition {
required uint32 weight = 31;
required string dev_name = 32;
optional Equalizer equalizer = 33;
optional I18nString name_full = 34;
}
message Equalizer {
@@ -292,6 +292,7 @@ export interface TankDefinition {
weight: number;
dev_name: string;
equalizer?: Equalizer | undefined;
name_full?: I18nString | undefined;
}
export interface TankDefinition_RolesEntry {
@@ -651,6 +652,7 @@ function createBaseTankDefinition(): TankDefinition {
weight: 0,
dev_name: "",
equalizer: undefined,
name_full: undefined,
};
}
@@ -752,6 +754,9 @@ export const TankDefinition: MessageFns<TankDefinition> = {
if (message.equalizer !== undefined) {
Equalizer.encode(message.equalizer, writer.uint32(266).fork()).join();
}
if (message.name_full !== undefined) {
I18nString.encode(message.name_full, writer.uint32(274).fork()).join();
}
return writer;
},
@@ -1051,6 +1056,14 @@ export const TankDefinition: MessageFns<TankDefinition> = {
message.equalizer = Equalizer.decode(reader, reader.uint32());
continue;
}
case 34: {
if (tag !== 274) {
break;
}
message.name_full = I18nString.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -1111,6 +1124,7 @@ export const TankDefinition: MessageFns<TankDefinition> = {
weight: isSet(object.weight) ? globalThis.Number(object.weight) : 0,
dev_name: isSet(object.dev_name) ? globalThis.String(object.dev_name) : "",
equalizer: isSet(object.equalizer) ? Equalizer.fromJSON(object.equalizer) : undefined,
name_full: isSet(object.name_full) ? I18nString.fromJSON(object.name_full) : undefined,
};
},
@@ -1218,6 +1232,9 @@ export const TankDefinition: MessageFns<TankDefinition> = {
if (message.equalizer !== undefined) {
obj.equalizer = Equalizer.toJSON(message.equalizer);
}
if (message.name_full !== undefined) {
obj.name_full = I18nString.toJSON(message.name_full);
}
return obj;
},
@@ -1271,6 +1288,9 @@ export const TankDefinition: MessageFns<TankDefinition> = {
message.equalizer = (object.equalizer !== undefined && object.equalizer !== null)
? Equalizer.fromPartial(object.equalizer)
: undefined;
message.name_full = (object.name_full !== undefined && object.name_full !== null)
? I18nString.fromPartial(object.name_full)
: undefined;
return message;
},
};
@@ -46,7 +46,8 @@ export function SearchBar({ topResult, skeleton, onSelect }: SearchBarProps) {
}, [searching]);
const handleKeyDown = useCallback<KeyboardEventHandler>(
(event) => {
if (event.key !== "Enter" || !topResult || searching) return;
if (event.key !== "Enter" || !topResult) return;
if (!TankFilters.state.search || TankFilters.state.searching) return;
event.preventDefault();