Skip to content

feat: add option to move search bar up when header is empty#142

Open
Reenallarealo wants to merge 3 commits intoprem-k-r:mainfrom
Reenallarealo:feature/move-search-up
Open

feat: add option to move search bar up when header is empty#142
Reenallarealo wants to merge 3 commits intoprem-k-r:mainfrom
Reenallarealo:feature/move-search-up

Conversation

@Reenallarealo
Copy link

@Reenallarealo Reenallarealo commented Feb 12, 2026

📌 Description

Title: feat: add option to move search bar up when header is empty

Description When the clock, weather, and search engines are all hidden, the top area becomes empty. I added a toggle to move the search bar upward to fill this gap.

How it works:

The code logic was constructed with the help of Claude and Gemini.

Positioning & Suggestions: It moves the search bar up using max(-160px, -20vh). To make use of the extra space, I also increased the search suggestion box (resultBox) height by about 2 rows so it fills the screen better.

Animation Logic:

No animation on load: When you first open a tab, the search bar is already in position. There is no "sliding up" motion.

Manual toggle only: The smooth animation only triggers when you manually click the switch in settings.

Safety: I used Media Queries to ensure that on very short windows, the search bar doesn't hit the top of the screen.

i18n: Added translations for English, Simplified Chinese, and Traditional Chinese.

Testing

Browser: Only tested on Microsoft Edge. I haven't verified it on Firefox or other browsers yet.

Responsive: Tested by resizing the window manually to ensure it doesn't overlap with other elements.

🎨 Visual Changes (Screenshots / Videos)

屏幕截图 2026-02-13 002352 屏幕截图 2026-02-13 002418 屏幕截图 2026-02-13 002644

✅ Checklist

[x] I have read and followed the Contributing Guidelines.

[x] My code follows the project's coding style and conventions.

[x] I have tested my changes thoroughly.

[ ] I have verified compatibility across Chrome and Firefox (Tested on Microsoft Edge only).

[ ] I have updated the CHANGELOG.md.

Overview

This PR adds an optional setting to automatically move the search bar upward when the header area is empty (clock, weather, and search engines all hidden), improving space use and visual balance on the new tab page.

Changes

New Feature: Move Search Bar Up

  • Added scripts/move-search-up.js: controls behavior and persistence.
    • Loads/saves moveSearchUpEnabled in localStorage.
    • Moves the center container (.centerDiv) by toggling the .search-moved-up class when the "Move Search Bar Up" toggle is enabled AND all three conditions (hide clock, hide weather, hide search engines) are true.
    • Applies initial position immediately (no animation on load).
    • On enabling the toggle, automatically hides clock, weather, and search engines by triggering their toggles (click()).
    • If any of the three are re-enabled by the user, the move-search-up setting is disabled and persisted.
    • Adds body.user-is-interacting on the first user interaction to enable smooth animation for subsequent changes.
    • Guards and logs a warning if required DOM elements are missing.

UI Updates

  • index.html: inserted a new toggle block in the Search settings:
    • Elements: moveSearchUpToggle container, moveSearchUpText, moveSearchUpInfo, moveSearchUpCheckbox.

Styling & Positioning

  • style.css:
    • New CSS var --search-suggestions-extra-rows: 88px.
    • .centerDiv.search-moved-up uses transform: translateY(max(-160px, -20vh)) to lift the center area.
    • resultBox max-height increased when moved up (calc with --search-suggestions-extra-rows) to gain ~2 extra suggestion rows.
    • Transition disabled on initial load (transition: 0s) and enabled after user interaction via body.user-is-interacting .centerDiv { transition: transform 0.5s var(--md-motion-ease); }.
    • Responsive caps to prevent the centerDiv from hitting the top: -100px at max-height:700px and -50px at max-height:500px.

Localization

  • locales/en.js, locales/zh.js, locales/zh_TW.js: added moveSearchUpText and moveSearchUpInfo translations.
  • scripts/languages.js: added keys to translationMap so the new strings are applied.

Behavior & Safety

  • No initial animation to avoid jarring layout shift on page load.
  • Uses media queries and capped translateY values to avoid overlapping the top on short windows.
  • Feature is opt-in and persisted; enabling the feature auto-hides the three header elements to ensure the condition is met.

Testing

  • Manually tested in Microsoft Edge with window resizing for responsive behavior.
  • Cross-browser verification (Firefox and others) and CHANGELOG update not completed.

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

Adds a new "Move Search Bar Up" UI toggle, localized strings, CSS for a moved-up state with responsive rules and animations, and a new client script that persists and enforces the position based on three condition checkboxes and user interaction.

Changes

Cohort / File(s) Summary
UI & Script Integration
index.html
Included scripts/move-search-up.js (defer) and added a new toggle block in the Search section (moveSearchUpToggle, checkbox moveSearchUpCheckbox).
Localization
locales/en.js, locales/zh.js, locales/zh_TW.js, scripts/languages.js
Added moveSearchUpText and moveSearchUpInfo translations and wired them into the translation map.
Search Movement Logic
scripts/move-search-up.js
New script that loads/saves moveSearchUpEnabled to localStorage, evaluates three condition checkboxes, toggles .search-moved-up on .centerDiv, and handles user interactions and persistence.
Styling & Animation
style.css
Added --search-suggestions-extra-rows, .centerDiv.search-moved-up transforms, responsive transform adjustments, resultBox max-heights, and transition rules gated by body.user-is-interacting.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant DOM as Page / Script
    participant Storage as localStorage
    participant CSS as Styles

    User->>DOM: load page
    DOM->>Storage: read moveSearchUpEnabled
    DOM->>DOM: checkConditions(hideClock, hideWeather, shortcuts)
    DOM->>CSS: applySearchPosition(add/remove .search-moved-up)

    User->>DOM: toggle moveSearchUpCheckbox
    activate DOM
    DOM->>DOM: mark user-is-interacting
    DOM->>DOM: auto-click condition checkboxes (if enabling)
    DOM->>Storage: persist moveSearchUpEnabled
    DOM->>CSS: add/remove .search-moved-up
    deactivate DOM

    User->>DOM: change a condition checkbox
    activate DOM
    DOM->>DOM: mark user-is-interacting
    DOM->>DOM: re-evaluate checkConditions
    DOM->>Storage: persist updated moveSearchUpEnabled (may disable)
    DOM->>CSS: reapply .search-moved-up as needed
    deactivate DOM
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

ui/ux, i18n/l10n

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add option to move search bar up when header is empty' clearly and concisely summarizes the main change—adding a toggle to move the search bar upward when header elements are hidden.
Description check ✅ Passed The description includes a clear explanation of the feature, implementation details (positioning, animation, safety), i18n support, and testing notes. However, two checklist items remain incomplete: cross-browser verification (only Edge tested) and CHANGELOG.md update.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
style.css (1)

1469-1477: user-is-interacting class is never removed — transitions stay enabled permanently.

Once a user toggles any checkbox, body.user-is-interacting is added and never cleared. This means every future .centerDiv transform change (including those triggered by responsive layout shifts on resize) will animate with a 0.5s transition. Consider removing the class after the transition ends to keep the animation scoped to intentional toggles.

scripts/move-search-up.js (1)

49-70: Using .click() to programmatically toggle other checkboxes has side effects.

Each .click() call synchronously fires change events on those checkboxes, which triggers their listeners (lines 74–84). Each of those listeners calls applySearchPosition(), so it runs 3 extra times before line 69 calls it again. This is functionally correct but redundant.

Consider setting .checked directly and dispatching a single synthetic event (or calling the relevant hide/show functions directly) to avoid cascading redundant work.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@style.css`:
- Around line 1460-1497: Fix three Stylelint failures in the move-up block: (1)
normalize comment spacing by ensuring a single space after /* and before */ in
all comments in this block; (2) resolve selector-class-pattern violations for
.centerDiv and .resultBox by either renaming those classes to kebab-case (e.g.,
.center-div and .result-box) and updating all HTML/JS references, or, if
renaming is undesirable, add an inline suppression around the block using /*
stylelint-disable selector-class-pattern */ before the selectors and /*
stylelint-enable selector-class-pattern */ after; (3) address the range/notation
lint by making the transform expression stylelint-friendly (if your rule flags
the max() usage, replace translateY(max(-160px, -20vh)) with a supported
equivalent or wrap a suppression comment /* stylelint-disable-value */ for that
property). Apply these changes to the selectors .centerDiv.search-moved-up,
.centerDiv.search-moved-up .resultBox and body.user-is-interacting .centerDiv to
clear the Stylelint errors.
🧹 Nitpick comments (1)
scripts/move-search-up.js (1)

9-20: Add a defensive guard for missing DOM nodes.
Prevents runtime errors if this script ever loads on a page lacking these elements.

🛡️ Suggested guard
 document.addEventListener("DOMContentLoaded", function () {
     const moveSearchUpCheckbox = document.getElementById("moveSearchUpCheckbox");
     const centerDiv = document.querySelector(".centerDiv");
     
     const hideClockCheckbox = document.getElementById("hideClock");
     const hideWeatherCheckbox = document.getElementById("hideWeatherCheckbox");
     const hideSearchWithCheckbox = document.getElementById("shortcut_switchcheckbox");
+
+    if (!moveSearchUpCheckbox || !centerDiv || !hideClockCheckbox || !hideWeatherCheckbox || !hideSearchWithCheckbox) {
+        return;
+    }

@itz-rj-here itz-rj-here added enhancement New feature or request under-review Currently being reviewed. Please wait for feedback. labels Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request under-review Currently being reviewed. Please wait for feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants