[PR #2887] [MERGED] Creative inventory: fix the search box keeping the last search after closing #4672

Closed
opened 2026-11-03 05:07:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2887
Author: @masa-masa-0314
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/creative-search-reset-on-open


📝 Commits (1)

  • e6c1a91 creative: rebuild the search state when the screen opens

📊 Changes

3 files changed (+23 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/creative.rs (+13 -0)
📝 crates/horizon-client/src/game.rs (+5 -4)
📝 crates/horizon-client/src/game/remote.rs (+5 -4)

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally.

What and why

In creative mode, typing into the search tab and closing the inventory kept the search: reopening still showed the old text and its filtered grid (#2873).

Horizon keeps one Creative for the game's whole lifetime (Game::creative_screen), so the search EditBox, its focus and the grid scroll all survived a close/reopen. Vanilla builds a fresh CreativeModeInventoryScreen on every open: init() constructs a new search box and the scrollbar starts at the top; only the tab survives (its static selectedTab). A new Creative::reopen applies that at both open paths (the local key handler and the remote one): empty the box, reset the scrollbar, and focus the box on the search tab — the state selectTab produces on a reopened screen. Switching tabs inside the screen still matches selectTab (a different tab empties the box), and the text is still preserved while the screen stays open (vanilla's resize).

Fixes #2873.

Vanilla reference

Decompiled from the 26.3 client jar, net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen:

  • init() — a new EditBox per open; it swaps selectedTab with the default tab before calling selectTab(tab), so a reopened screen always takes the oldTab != tab branch: searchBox.setValue(""), setFocused(true) on the search tab.
  • resize() — the only place the search text is carried over (same open, window resize).
  • scrollOffs is an instance field: zero on each open.

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on DESKTOP-3050AHP, against upstream/main at 9972feb71, 7 min 37 s)

Check Result
Scope ✅ 3 files, +23 −8
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 364 run, FAILED (failures=2, errors=7, skipped=1) (1 min 38 s)
rustfmt ✅ (13 s)
clippy ✅ (1 min 5 s)
tests: horizon-client ❌ 1160 passed, 2 failed (3 min 22 s)
doc tests ✅ (1 min 15 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

All failures are pre-existing on clean upstream/main on this Windows machine, proven by stashing the change:

  • horizon-client lib: save::tests::session_lock_is_exclusive (the OS reports the lock file locked) and crash::tests::stacks_start_at_the_panicking_frame (backtrace path format) — the two known Windows failures.
  • Python: the same 2 failures + 7 errors (test_parity_reach, test_port_publish, test_port_harness) also fail with the change stashed.

A temporary focused test (reopen clears the box's text, cursor and selection, zeroes the scroll, keeps the selected tab and focuses the box only on the search tab) passed; it was removed from this diff as the project asks.

Screenshots

Not attached: this machine's offscreen renderer shows a blank window. The change is a pure state reset, verified by the checks above.

🤖 Generated with ZCode


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2887 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/creative-search-reset-on-open` --- ### 📝 Commits (1) - [`e6c1a91`](https://github.com/horizon-rust/horizon/commit/e6c1a91a6549d6fb3128f95ae5b7c88dba4a4e6d) creative: rebuild the search state when the screen opens ### 📊 Changes **3 files changed** (+23 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/creative.rs` (+13 -0) 📝 `crates/horizon-client/src/game.rs` (+5 -4) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -4) </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally. ## What and why In creative mode, typing into the search tab and closing the inventory kept the search: reopening still showed the old text and its filtered grid (#2873). Horizon keeps one `Creative` for the game's whole lifetime (`Game::creative_screen`), so the search `EditBox`, its focus and the grid scroll all survived a close/reopen. Vanilla builds a fresh `CreativeModeInventoryScreen` on every open: `init()` constructs a new search box and the scrollbar starts at the top; only the tab survives (its static `selectedTab`). A new `Creative::reopen` applies that at both open paths (the local key handler and the remote one): empty the box, reset the scrollbar, and focus the box on the search tab — the state `selectTab` produces on a reopened screen. Switching tabs inside the screen still matches `selectTab` (a different tab empties the box), and the text is still preserved while the screen stays open (vanilla's `resize`). Fixes #2873. ## Vanilla reference Decompiled from the 26.3 client jar, `net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen`: - `init()` — a new `EditBox` per open; it swaps `selectedTab` with the default tab before calling `selectTab(tab)`, so a reopened screen always takes the `oldTab != tab` branch: `searchBox.setValue("")`, `setFocused(true)` on the search tab. - `resize()` — the only place the search text is carried over (same open, window resize). - `scrollOffs` is an instance field: zero on each open. ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on DESKTOP-3050AHP, against upstream/main at 9972feb71, 7 min 37 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +23 −8 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 364 run, FAILED (failures=2, errors=7, skipped=1) (1 min 38 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (1 min 5 s) | | tests: horizon-client | ❌ 1160 passed, 2 failed (3 min 22 s) | | doc tests | ✅ (1 min 15 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | All failures are pre-existing on clean `upstream/main` on this Windows machine, proven by stashing the change: - `horizon-client` lib: `save::tests::session_lock_is_exclusive` (the OS reports the lock file locked) and `crash::tests::stacks_start_at_the_panicking_frame` (backtrace path format) — the two known Windows failures. - Python: the same 2 failures + 7 errors (`test_parity_reach`, `test_port_publish`, `test_port_harness`) also fail with the change stashed. A temporary focused test (reopen clears the box's text, cursor and selection, zeroes the scroll, keeps the selected tab and focuses the box only on the search tab) passed; it was removed from this diff as the project asks. ## Screenshots Not attached: this machine's offscreen renderer shows a blank window. The change is a pure state reset, verified by the checks above. 🤖 Generated with ZCode --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:05 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4672
No description provided.