Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Improve search input stability during view transitions

Maximilian Roos68db3fcc8e0c
diff --git a/docs/sass/custom.scss b/docs/sass/custom.scss
index 1f0c5edfd..44c2d425b 100644
--- a/docs/sass/custom.scss
+++ b/docs/sass/custom.scss
@@ -199,6 +199,20 @@ nav {
.search-container {
position: relative;
margin-right: 1rem;
+
+ // Keep input expanded while anything in container has focus (including
+ // clicking a search result link). Prevents jarring shrink during navigation.
+ &:focus-within #userinput {
+ width: 240px;
+ border-color: var(--wt-color-accent);
+ }
+
+ // Freeze search container during view transitions to prevent layout shift.
+ // Without this, focus loss during transition causes input to shrink.
+ // Progressive enhancement: View Transitions API (Chrome 111+, Safari 18+)
+ &:focus-within {
+ view-transition-name: search-frozen;
+ }
}
#userinput {
@@ -215,12 +229,6 @@ nav {
&::placeholder {
color: var(--wt-color-text-soft);
}
-
- &:focus {
- width: 240px;
- border-color: var(--wt-color-accent);
- outline: none;
- }
}
#suggestions {
@@ -1096,6 +1104,12 @@ body.mobile-menu-open {
animation-duration: 50ms;
}
+// Freeze focused search box during transition - no animation, just cross-fade
+::view-transition-old(search-frozen),
+::view-transition-new(search-frozen) {
+ animation: none;
+}
+
// ============================================================================
// Transitions & Accessibility
// ============================================================================
diff --git a/docs/static/search.js b/docs/static/search.js
index c83688269..b45e55ee5 100644
--- a/docs/static/search.js
+++ b/docs/static/search.js
@@ -84,10 +84,14 @@ document.addEventListener('keydown', function(e) {
});
});
- // Clear suggestions when clicking a result
- suggestions.addEventListener('click', function() {
- suggestions.innerHTML = '';
- suggestions.style.display = 'none';
+ // Only hide suggestions on modifier-click (opens in new tab).
+ // Normal clicks navigate away, so the page resets naturally.
+ // Clearing during navigation causes layout shift during the view transition.
+ suggestions.addEventListener('click', function(e) {
+ if (e.ctrlKey || e.metaKey || e.shiftKey) {
+ suggestions.innerHTML = '';
+ suggestions.style.display = 'none';
+ }
});
function escapeHtml(text) {