|
2 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
|
5 | | -import React, { useContext, useEffect, useLayoutEffect, useRef } from "react"; |
| 5 | +import React, { useContext, useEffect, useRef } from "react"; |
6 | 6 | import { useDispatch, useSelector, batch } from "react-redux"; |
7 | 7 | import { BaseContext } from "content-src/lib/BaseContext"; |
8 | 8 | // Bug 2034542: these per-widget imports can be removed once the non-Nova render |
@@ -50,9 +50,6 @@ const PREF_WIDGETS_FEEDBACK_ENABLED = "widgets.feedback.enabled"; |
50 | 50 | const PREF_WIDGETS_HIDE_ALL_TOAST_ENABLED = "widgets.hideAllToast.enabled"; |
51 | 51 | const WIDGETS_FEEDBACK_URL = |
52 | 52 | "https://support.mozilla.org/kb/firefox-new-tab-widgets"; |
53 | | -// Safety net in case transitionend never fires. Keep this above the CSS |
54 | | -// height transition duration (--widget-size-transition-duration, 180ms). |
55 | | -const ROW_TOGGLE_HEIGHT_ANIMATION_FALLBACK_MS = 300; |
56 | 53 |
|
57 | 54 | // resets timer to default values (exported for testing) |
58 | 55 | // In practice, this logic runs inside a useEffect when |
@@ -296,52 +293,6 @@ function Widgets() { |
296 | 293 | // track previous timerEnabled state to detect when it becomes disabled |
297 | 294 | const prevTimerEnabledRef = useRef(timerEnabled); |
298 | 295 |
|
299 | | - const rowToggleFromHeightRef = useRef(null); |
300 | | - |
301 | | - useLayoutEffect(() => { |
302 | | - const fromHeight = rowToggleFromHeightRef.current; |
303 | | - rowToggleFromHeightRef.current = null; |
304 | | - const container = widgetsContainerRef.current; |
305 | | - if (fromHeight === null || !container) { |
306 | | - return undefined; |
307 | | - } |
308 | | - const toHeight = container.getBoundingClientRect().height; |
309 | | - if (fromHeight === toHeight) { |
310 | | - return undefined; |
311 | | - } |
312 | | - container.style.height = `${fromHeight}px`; |
313 | | - container.classList.add("is-animating-height"); |
314 | | - // Commit the start height before transitioning to the target. |
315 | | - void container.offsetHeight; |
316 | | - container.style.height = `${toHeight}px`; |
317 | | - |
318 | | - let fallbackTimer; |
319 | | - // Invoked from transitionend/transitioncancel (with an event), from the |
320 | | - // fallback timer, or as the effect cleanup (no event). Ignore events |
321 | | - // bubbling up from child widgets; the container only transitions height, |
322 | | - // so its own events need no propertyName check. |
323 | | - const finishRowHeightAnimation = e => { |
324 | | - if (e && e.target !== container) { |
325 | | - return; |
326 | | - } |
327 | | - globalThis.clearTimeout(fallbackTimer); |
328 | | - container.style.height = ""; |
329 | | - container.classList.remove("is-animating-height"); |
330 | | - container.removeEventListener("transitionend", finishRowHeightAnimation); |
331 | | - container.removeEventListener( |
332 | | - "transitioncancel", |
333 | | - finishRowHeightAnimation |
334 | | - ); |
335 | | - }; |
336 | | - container.addEventListener("transitionend", finishRowHeightAnimation); |
337 | | - container.addEventListener("transitioncancel", finishRowHeightAnimation); |
338 | | - fallbackTimer = globalThis.setTimeout( |
339 | | - finishRowHeightAnimation, |
340 | | - ROW_TOGGLE_HEIGHT_ANIMATION_FALLBACK_MS |
341 | | - ); |
342 | | - return finishRowHeightAnimation; |
343 | | - }, [rowExpanded]); |
344 | | - |
345 | 296 | // Reset timer when it becomes disabled |
346 | 297 | useEffect(() => { |
347 | 298 | const wasTimerEnabled = prevTimerEnabledRef.current; |
@@ -481,13 +432,6 @@ function Widgets() { |
481 | 432 |
|
482 | 433 | function toggleRowExpanded() { |
483 | 434 | const next = !rowExpanded; |
484 | | - const container = widgetsContainerRef.current; |
485 | | - const prefersReducedMotion = globalThis.matchMedia?.( |
486 | | - "(prefers-reduced-motion: reduce)" |
487 | | - )?.matches; |
488 | | - if (container && !prefersReducedMotion) { |
489 | | - rowToggleFromHeightRef.current = container.getBoundingClientRect().height; |
490 | | - } |
491 | 435 | batch(() => { |
492 | 436 | dispatch(ac.SetPref(PREF_WIDGETS_ROW_EXPANDED, next)); |
493 | 437 | dispatch( |
|
0 commit comments