-
Notifications
You must be signed in to change notification settings - Fork 114
Added search box hide button #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -670,7 +670,7 @@ <h2 id="editBookmarkHeading">Edit Bookmark</h2> | |
| <!-- ------end of weather stuff------------ --> | ||
|
|
||
| <!-- ----------searchbar-------------- --> | ||
| <div class="searchbar bgLightTint" id="searchbar"> | ||
| <div class="searchbar bgLightTint" id="searchbar" style="visibility: visible;"> | ||
|
|
||
| <div class="searchIcon"> | ||
| <svg fill="none" height="100%" viewBox="0 0 45 45" width="100%" xmlns="http://www.w3.org/2000/svg"> | ||
|
|
@@ -1476,6 +1476,17 @@ <h1>Material You New Tab</h1> | |
| </label> | ||
| </div> | ||
|
|
||
| <div class="ttcont"> | ||
| <div class="texts"> | ||
| <div class="bigText" id="hideSearchBox">Hide Search Box</div> | ||
| <div class="infoText" id="hideSearchBoxInfo">If you do not want search box</div> | ||
| </div> | ||
| <label class="switch"> | ||
| <input id="searchBoxCheckBox" type="checkbox"> | ||
| <span class="toggle"></span> | ||
| </label> | ||
| </div> | ||
|
Comment on lines
+1479
to
+1488
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n --hidden --glob '!**/node_modules/**' -S 'hideSearchBoxInfo|hideSearchBox' .Repository: prem-k-r/MaterialYouNewTab Length of output: 562 🏁 Script executed: fd -t f -e json -e js -e yml -e yaml . | grep -E '(locale|i18n|lang|translation)' | head -20Repository: prem-k-r/MaterialYouNewTab Length of output: 353 🏁 Script executed: # Check the structure of a locale file
head -50 locales/en.jsRepository: prem-k-r/MaterialYouNewTab Length of output: 1967 🏁 Script executed: # Search for the new text strings in all locale files
rg -n 'Hide Search Box|If you do not want search box' locales/Repository: prem-k-r/MaterialYouNewTab Length of output: 52 🏁 Script executed: # Count locale files
ls -1 locales/*.js | wc -l
# Show all locale files
ls -1 locales/*.js | xargs -I {} basename {}Repository: prem-k-r/MaterialYouNewTab Length of output: 265 🏁 Script executed: # Check if there's a pattern for how "Hide X" settings are translated
rg -n '"hide' locales/ -i | head -20Repository: prem-k-r/MaterialYouNewTab Length of output: 1428 Add translations for "Hide Search Box" setting across all 31 locale files. The IDs Additionally, refine the English copy from "If you do not want search box" to "If you don't want the search box" (or similar) to match the phrasing pattern used in comparable settings. 🤖 Prompt for AI Agents |
||
|
|
||
| <div class="ttcont" id="quotesToggle"> | ||
| <div class="texts"> | ||
| <div class="bigText" id="motivationalQuotesText">Motivational Quotes</div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -414,3 +414,43 @@ document.addEventListener("keydown", function (event) { | |||||
| searchbar.classList.add("active"); | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
|
|
||||||
| /* ------ Event Listeners for Searchbar ------ */ | ||||||
| const showSearchbar = () => { | ||||||
| document.getElementById("searchbar").style.visibility = "visible"; | ||||||
| } | ||||||
|
|
||||||
| const hideSearchbar = () => { | ||||||
| document.getElementById("searchbar").style.visibility = "hidden"; | ||||||
| } | ||||||
|
|
||||||
| const initSearchBarswitch = (element) => { | ||||||
|
||||||
| if (element.checked) { | ||||||
| hideSearchbar(); | ||||||
| localStorage.setItem("showSearchBarswitch", true); | ||||||
| } else { | ||||||
| showSearchbar(); | ||||||
| localStorage.setItem("showSearchBarswitch", false); | ||||||
|
Comment on lines
+431
to
+434
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| const hideSearchBox = document.getElementById("searchBoxCheckBox"); | ||||||
| hideSearchBox.addEventListener("change", (e) => { | ||||||
| initSearchBarswitch(e.target); | ||||||
| }); | ||||||
|
|
||||||
| if (localStorage.getItem("showSearchBarswitch")) { | ||||||
| const isSearchBarswitchEnabled = localStorage.getItem("showSearchBarswitch").toString() === "true"; | ||||||
| document.getElementById("searchBoxCheckBox").checked = isSearchBarswitchEnabled; | ||||||
|
|
||||||
| if (isSearchBarswitchEnabled) { | ||||||
| hideSearchbar(); | ||||||
| } else if (!isShortCutSwitchEnabled) { | ||||||
|
||||||
| } else if (!isShortCutSwitchEnabled) { | |
| } else if (!isSearchBarswitchEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix ReferenceError (isShortCutSwitchEnabled) and prefer a “real hide” (hidden / display:none) over visibility.
- Line 449:
isShortCutSwitchEnabledisn’t defined in this scope; if the user hasshowSearchBarswitch=false, this path can crash the script. - UX:
visibility: hiddenleaves empty space and still permits focusing hidden inputs; considersearchbar.hidden = true/false(or a CSS class that setsdisplay: none). - Naming: consider storing
hideSearchBox=true/falseto match the checkbox meaning.
Proposed fix (scoped to this block)
/* ------ Event Listeners for Searchbar ------ */
-const showSearchbar = () => {
- document.getElementById("searchbar").style.visibility = "visible";
-}
-
-const hideSearchbar = () => {
- document.getElementById("searchbar").style.visibility = "hidden";
-}
+const setSearchbarHidden = (hidden) => {
+ // "hidden" collapses layout and avoids focusing invisible controls
+ searchbar.hidden = hidden;
+}
const initSearchBarswitch = (element) => {
- if (element.checked) {
- hideSearchbar();
- localStorage.setItem("showSearchBarswitch", true);
- } else {
- showSearchbar();
- localStorage.setItem("showSearchBarswitch", false);
- }
+ const hidden = Boolean(element.checked); // checked == hide
+ setSearchbarHidden(hidden);
+ localStorage.setItem("hideSearchBox", String(hidden));
}
const hideSearchBox = document.getElementById("searchBoxCheckBox");
hideSearchBox.addEventListener("change", (e) => {
initSearchBarswitch(e.target);
});
-if (localStorage.getItem("showSearchBarswitch")) {
- const isSearchBarswitchEnabled = localStorage.getItem("showSearchBarswitch").toString() === "true";
- document.getElementById("searchBoxCheckBox").checked = isSearchBarswitchEnabled;
-
-if (isSearchBarswitchEnabled) {
- hideSearchbar();
- } else if (!isShortCutSwitchEnabled) {
- showSearchbar();
- }
-} else {
- localStorage.setItem("showSearchBarswitch", false);
-}
+const isSearchBoxHidden = localStorage.getItem("hideSearchBox") === "true";
+hideSearchBox.checked = isSearchBoxHidden;
+setSearchbarHidden(isSearchBoxHidden);
initSearchBarswitch(hideSearchBox);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this entry to
[Unreleased](it’s currently recorded underv3.2).Right now the feature is documented as if it shipped on July 20, 2025, which is misleading for this PR.
Proposed change
📝 Committable suggestion
🤖 Prompt for AI Agents