forge
Explore
Log in

Don't you dare go Hollow

Typing in the drive search no longer reshuffles the bar

Browse files at this commit

888f97d5223493cac29249a159b243dac8f5ed71Ahmet Kaan GümüşParent: 6d149b1
  • fix
    • typing in the drive search no longer reshuffles the bar
Show full message
fix(ui): typing in the drive search no longer reshuffles the bar

Two stacked causes. The search caption rendered inside the filterbar
only in search mode, so each type-as-filter keystroke inserted a
leading bar child and pushed the search box sideways mid-typing. And
the soft-nav morpher paired children purely by position: a leading
child coming or going shifted every later sibling one slot, morphing
the sort form into the search form — its enhanced dropdown trigger
ended up inside the search box and the focused input was replaced
under the typist.

The caption now rides inside the results panel, keeping the bar's
children the same set in every mode; the morpher gained one node of
lookahead, so a child that appears or vanishes is inserted or removed
where it stands instead of cascading replacements down the row — the
same cascade the crumbs nav triggered on folder navigation.
crates/in-web/src/drive.rsmodified+20 -12
@@ -454,6 +454,12 @@ async fn drive(cx: &Cx) -> Result {
454 None => None,454 None => None,
455 };455 };
456 let box_text = asked.clone().unwrap_or_default();456 let box_text = asked.clone().unwrap_or_default();
457+ // The search mode tell: rendered inside the results panel, never in the
458+ // filterbar — the bar keeps one shape whether the list below is a folder
459+ // or hits, so typing in the box never reshuffles the controls around it.
460+ let caption = asked
461+ .as_deref()
462+ .map(|query| format!("{} “{query}”", t(language, Key::SearchResults)));
457 let current = current_folder(store.as_ref(), &user.id, wanted.as_deref()).await?;463 let current = current_folder(store.as_ref(), &user.id, wanted.as_deref()).await?;
458 let crumbs = breadcrumbs(store.as_ref(), current.as_ref()).await;464 let crumbs = breadcrumbs(store.as_ref(), current.as_ref()).await;
459 let mut listing = match store465 let mut listing = match store
@@ -567,18 +573,18 @@ async fn drive(cx: &Cx) -> Result {
567 (topbar(cx, NavPage::Drive, &user, language).await?)573 (topbar(cx, NavPage::Drive, &user, language).await?)
568 <main class="settings-stage stage-wide">574 <main class="settings-stage stage-wide">
569 <div class="filterbar drive-bar">575 <div class="filterbar drive-bar">
570- if let Some(query) = asked.as_deref() {576+ // The bar's children stay the same set in every mode — a
571- <p class="detail-quiet">(t(language, Key::SearchResults)) (format!(" “{query}”"))</p>577+ // leading element that comes and goes would shift the morph's
572- } else {578+ // positional pairing and shuffle the forms into each other.
573- if current.is_some() {579+ // The search caption lives in the results panel instead.
574- <nav class="detail-crumbs" aria-label=(current_name.clone())>580+ if asked.is_none() && current.is_some() {
575- <a class="detail-crumb" href="/drive">(t(language, Key::Drive))</a>581+ <nav class="detail-crumbs" aria-label=(current_name.clone())>
576- for crumb in crumbs.iter() {582+ <a class="detail-crumb" href="/drive">(t(language, Key::Drive))</a>
577- <span class="detail-crumb-sep">"/"</span>583+ for crumb in crumbs.iter() {
578- <a class="detail-crumb" href=(format!("/drive?folder={}", crumb.id))>(crumb.name.clone())</a>584+ <span class="detail-crumb-sep">"/"</span>
579- }585+ <a class="detail-crumb" href=(format!("/drive?folder={}", crumb.id))>(crumb.name.clone())</a>
580- </nav>586+ }
581- }587+ </nav>
582 }588 }
583 <form class="field-box field-box-search" method="get" action="/drive">589 <form class="field-box field-box-search" method="get" action="/drive">
584 <input590 <input
@@ -675,6 +681,7 @@ async fn drive(cx: &Cx) -> Result {
675 if let Some(hits) = hits {681 if let Some(hits) = hits {
676 if hits.folders.is_empty() && hits.files.is_empty() {682 if hits.folders.is_empty() && hits.files.is_empty() {
677 <section class="panel drive-panel">683 <section class="panel drive-panel">
684+ <p class="drive-results-note">(caption.clone().unwrap_or_default())</p>
678 <div class="drive-empty">685 <div class="drive-empty">
679 <span class="drive-empty-glyph" aria-hidden="true">"▤"</span>686 <span class="drive-empty-glyph" aria-hidden="true">"▤"</span>
680 <p class="drive-empty-text">(t(language, Key::NoResults))</p>687 <p class="drive-empty-text">(t(language, Key::NoResults))</p>
@@ -682,6 +689,7 @@ async fn drive(cx: &Cx) -> Result {
682 </section>689 </section>
683 } else {690 } else {
684 <section class="panel drive-panel">691 <section class="panel drive-panel">
692+ <p class="drive-results-note">(caption.clone().unwrap_or_default())</p>
685 <div class="drive-head">693 <div class="drive-head">
686 <span class="drive-cols">694 <span class="drive-cols">
687 <span class="drive-col-ico" aria-hidden="true"></span>695 <span class="drive-col-ico" aria-hidden="true"></span>
crates/in-web/src/layout.rsmodified+17 -6
@@ -426,16 +426,27 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
426 var mine = [], theirs = [], n; \426 var mine = [], theirs = [], n; \
427 for (n = from.firstChild; n; n = n.nextSibling) { if (!clientMade(n)) { mine.push(n); } } \427 for (n = from.firstChild; n; n = n.nextSibling) { if (!clientMade(n)) { mine.push(n); } } \
428 for (n = to.firstChild; n; n = n.nextSibling) { theirs.push(n); } \428 for (n = to.firstChild; n; n = n.nextSibling) { theirs.push(n); } \
429- var i; \429+ /* Positional pairing with one node of lookahead: a child that \
430- for (i = 0; i < theirs.length; i++) { \430+ appears or vanishes between modes (a caption, a crumbs nav) \
431+ is inserted or removed where it stands instead of shifting \
432+ every later sibling one slot — the plain positional pass \
433+ once morphed the sort form into the search box because the \
434+ search caption pushed both one position over. Identity is \
435+ kept whenever the tags line up one step either way. */ \
436+ var i = 0, j = 0; \
437+ while (j < theirs.length) { \
431 if (i < mine.length) { \438 if (i < mine.length) { \
432- if (pairable(mine[i], theirs[i])) { morph(mine[i], theirs[i]); } \439+ if (pairable(mine[i], theirs[j])) { morph(mine[i], theirs[j]); i++; j++; } \
433- else { mine[i].replaceWith(document.importNode(theirs[i], true)); } \440+ else if (i + 1 < mine.length && pairable(mine[i + 1], theirs[j])) { \
441+ from.insertBefore(document.importNode(theirs[j], true), mine[i]); j++; \
442+ } else if (j + 1 < theirs.length && pairable(mine[i], theirs[j + 1])) { \
443+ mine[i].remove(); i++; \
444+ } else { mine[i].replaceWith(document.importNode(theirs[j], true)); i++; j++; } \
434 } else { \445 } else { \
435- from.appendChild(document.importNode(theirs[i], true)); \446+ from.appendChild(document.importNode(theirs[j], true)); j++; \
436 } \447 } \
437 } \448 } \
438- for (i = theirs.length; i < mine.length; i++) { mine[i].remove(); } \449+ while (i < mine.length) { mine[i].remove(); i++; } \
439 } \450 } \
440 window.__inNav = 0; \451 window.__inNav = 0; \
441 function navStep() { return ++window.__inNav; } \452 function navStep() { return ++window.__inNav; } \
style/main.scssmodified+10 -0
@@ -5085,6 +5085,16 @@ div.member-row + div.member-row {
5085 white-space: nowrap;5085 white-space: nowrap;
5086 }5086 }
5087 5087
5088+// The search mode tell, inside the panel rather than the bar: a quiet line
5089+// over the column head, out of the way of the controls.
5090+.drive-results-note {
5091+ margin: 0;
5092+ padding: 10px 16px;
5093+ border-bottom: 1px solid var(--border);
5094+ font-size: 12px;
5095+ color: var(--muted);
5096+}
5097+
5088 .drive-cols {5098 .drive-cols {
5089 flex: 1;5099 flex: 1;
5090 min-width: 0;5100 min-width: 0;