commit a33c0e85699e439db041ed10d49309ac7beab990
parent ea57fcfbf3664ddfafefdd44359121ce6fec5d49
Author: Maxx Crawford <mcrawford@mozilla.com>
Date: Tue, 18 Nov 2025 17:57:56 +0000
Bug 1997673 - Add maximize/minimize icons for new tab r=home-newtab-reviewers,desktop-theme-reviewers,reemhamz
Differential Revision: https://phabricator.services.mozilla.com/D270926
Diffstat:
6 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/browser/extensions/newtab/content-src/components/Widgets/Widgets.jsx b/browser/extensions/newtab/content-src/components/Widgets/Widgets.jsx
@@ -89,17 +89,25 @@ function Widgets() {
// Update the ref to track current state
prevTimerEnabledRef.current = isTimerEnabled;
}, [timerEnabled, timerData, dispatch, timerType]);
+
// Sends a dispatch to disable all widgets
- const handleHideAllWidgets = e => {
- // TODO: Need safe way to iterate through all widgets
- // Handle both click events and keyboard events (Enter/Space)
- if (!e.key || e.key === "Enter" || e.key === " ") {
+ function handleHideAllWidgetsClick(e) {
+ e.preventDefault();
+ batch(() => {
+ dispatch(ac.SetPref(PREF_WIDGETS_LISTS_ENABLED, false));
+ dispatch(ac.SetPref(PREF_WIDGETS_TIMER_ENABLED, false));
+ });
+ }
+
+ function handleHideAllWidgetsKeyDown(e) {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
batch(() => {
dispatch(ac.SetPref(PREF_WIDGETS_LISTS_ENABLED, false));
dispatch(ac.SetPref(PREF_WIDGETS_TIMER_ENABLED, false));
});
}
- };
+ }
function handleUserInteraction(widgetName) {
const prefName = `widgets.${widgetName}.interaction`;
@@ -126,8 +134,8 @@ function Widgets() {
size="small"
data-l10n-id="newtab-widget-section-hide-all-button"
iconsrc="chrome://global/skin/icons/close.svg"
- onClick={handleHideAllWidgets}
- onKeyDown={handleHideAllWidgets}
+ onClick={handleHideAllWidgetsClick}
+ onKeyDown={handleHideAllWidgetsKeyDown}
/>
</div>
<div className="widgets-container">
diff --git a/browser/extensions/newtab/data/content/activity-stream.bundle.js b/browser/extensions/newtab/data/content/activity-stream.bundle.js
@@ -13595,17 +13595,24 @@ function Widgets() {
// Update the ref to track current state
prevTimerEnabledRef.current = isTimerEnabled;
}, [timerEnabled, timerData, dispatch, timerType]);
+
// Sends a dispatch to disable all widgets
- const handleHideAllWidgets = e => {
- // TODO: Need safe way to iterate through all widgets
- // Handle both click events and keyboard events (Enter/Space)
- if (!e.key || e.key === "Enter" || e.key === " ") {
+ function handleHideAllWidgetsClick(e) {
+ e.preventDefault();
+ (0,external_ReactRedux_namespaceObject.batch)(() => {
+ dispatch(actionCreators.SetPref(PREF_WIDGETS_LISTS_ENABLED, false));
+ dispatch(actionCreators.SetPref(PREF_WIDGETS_TIMER_ENABLED, false));
+ });
+ }
+ function handleHideAllWidgetsKeyDown(e) {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
(0,external_ReactRedux_namespaceObject.batch)(() => {
dispatch(actionCreators.SetPref(PREF_WIDGETS_LISTS_ENABLED, false));
dispatch(actionCreators.SetPref(PREF_WIDGETS_TIMER_ENABLED, false));
});
}
- };
+ }
function handleUserInteraction(widgetName) {
const prefName = `widgets.${widgetName}.interaction`;
const hasInteracted = prefs[prefName];
@@ -13631,8 +13638,8 @@ function Widgets() {
size: "small",
"data-l10n-id": "newtab-widget-section-hide-all-button",
iconsrc: "chrome://global/skin/icons/close.svg",
- onClick: handleHideAllWidgets,
- onKeyDown: handleHideAllWidgets
+ onClick: handleHideAllWidgetsClick,
+ onKeyDown: handleHideAllWidgetsKeyDown
})), /*#__PURE__*/external_React_default().createElement("div", {
className: "widgets-container"
}, listsEnabled && /*#__PURE__*/external_React_default().createElement(Lists, {
diff --git a/browser/extensions/newtab/test/unit/content-src/components/Widgets.test.jsx b/browser/extensions/newtab/test/unit/content-src/components/Widgets.test.jsx
@@ -172,7 +172,7 @@ describe("<Widgets>", () => {
// Get the onClick handler and call it
const onClickHandler = hideButton.prop("onClick");
assert.ok(onClickHandler, "onClick handler should exist");
- onClickHandler({});
+ onClickHandler({ preventDefault: () => {} });
const allCalls = store.dispatch.getCalls();
const setPrefCalls = allCalls.filter(
@@ -211,7 +211,7 @@ describe("<Widgets>", () => {
const hideButton = wrapper.find("#hide-all-widgets-button");
// Trigger onKeyDown handler directly with Enter key
- hideButton.prop("onKeyDown")({ key: "Enter" });
+ hideButton.prop("onKeyDown")({ key: "Enter", preventDefault: () => {} });
const setPrefCalls = store.dispatch
.getCalls()
@@ -249,7 +249,7 @@ describe("<Widgets>", () => {
const hideButton = wrapper.find("#hide-all-widgets-button");
// Trigger onKeyDown handler directly with Space key
- hideButton.prop("onKeyDown")({ key: " " });
+ hideButton.prop("onKeyDown")({ key: " ", preventDefault: () => {} });
const setPrefCalls = store.dispatch
.getCalls()
diff --git a/toolkit/themes/shared/desktop-jar.inc.mn b/toolkit/themes/shared/desktop-jar.inc.mn
@@ -84,6 +84,8 @@
skin/classic/global/icons/error.svg (../../shared/icons/error.svg)
skin/classic/global/icons/experiments.svg (../../shared/icons/experiments.svg)
skin/classic/global/icons/folder.svg (../../shared/icons/folder.svg)
+ skin/classic/global/icons/fullscreen.svg (../../shared/icons/fullscreen.svg)
+ skin/classic/global/icons/fullscreen-exit.svg (../../shared/icons/fullscreen-exit.svg)
skin/classic/global/icons/heart.svg (../../shared/icons/heart.svg)
skin/classic/global/icons/help.svg (../../shared/icons/help.svg)
skin/classic/global/icons/highlights.svg (../../shared/icons/highlights.svg)
diff --git a/toolkit/themes/shared/icons/fullscreen-exit.svg b/toolkit/themes/shared/icons/fullscreen-exit.svg
@@ -0,0 +1,7 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="context-fill" fill-opacity="context-fill-opacity">
+ <path d="M15.817.183a.626.626 0 0 0-.885 0l-3.625 3.625-.281-.281-1.173-1.173A.5.5 0 0 0 9 2.707L9 6.7l.3.3 3.993 0a.5.5 0 0 0 .354-.854l-1.454-1.454 3.625-3.625a.626.626 0 0 0-.001-.884z"/>
+ <path d="M3.707 8a.5.5 0 0 0-.354.854l1.454 1.454-3.625 3.625a.628.628 0 0 0 0 .885.63.63 0 0 0 .885-.001l3.625-3.625.281.281 1.173 1.173A.5.5 0 0 0 8 12.293L8 8.3 7.7 8 3.707 8z"/>
+</svg>
diff --git a/toolkit/themes/shared/icons/fullscreen.svg b/toolkit/themes/shared/icons/fullscreen.svg
@@ -0,0 +1,6 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="context-fill" fill-opacity="context-fill-opacity">
+ <path d="m14.7 1-3.993 0a.5.5 0 0 0-.354.854l1.454 1.454-7.5 7.5-1.454-1.454A.5.5 0 0 0 2 9.707L2 13.7l.3.3 3.993 0a.5.5 0 0 0 .354-.854l-1.454-1.454 7.5-7.5 1.454 1.454A.5.5 0 0 0 15 5.293L15 1.3l-.3-.3z"/>
+</svg>