diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-06-30 15:48:44 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-07-01 11:42:15 +0200 |
| commit | 830c390f2bc6cb73efe961afb9dee2cf54c02eb9 (patch) | |
| tree | a600520c5b7d58244a165982178f5c7cb7293da8 | |
| parent | 974c67cde7ada4898725070c0332b510157c2b32 (diff) | |
| download | mullvadvpn-830c390f2bc6cb73efe961afb9dee2cf54c02eb9.tar.xz mullvadvpn-830c390f2bc6cb73efe961afb9dee2cf54c02eb9.zip | |
Show notification content during hide-transition
| -rw-r--r-- | gui/src/renderer/components/NotificationBanner.tsx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gui/src/renderer/components/NotificationBanner.tsx b/gui/src/renderer/components/NotificationBanner.tsx index bddf075fb9..a4ee59f9ce 100644 --- a/gui/src/renderer/components/NotificationBanner.tsx +++ b/gui/src/renderer/components/NotificationBanner.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useLayoutEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; import styled from 'styled-components'; import { colors } from '../../config.json'; import { InAppNotificationIndicatorType } from '../../shared/notifications/notification'; @@ -145,6 +145,12 @@ export function NotificationBanner(props: INotificationBannerProps) { const contentRef = useRef() as React.RefObject<HTMLDivElement>; const collapsibleRef = useRef() as React.RefObject<HTMLDivElement>; + // Save last non-undefined children to be able to show them during the hide-transition. + const prevChildren = useRef<React.ReactNode>(); + useEffect(() => { + prevChildren.current = props.children ?? prevChildren.current; + }, [props.children]); + const onTransitionEnd = useCallback(() => setAlignBottom(false), []); useLayoutEffect(() => { @@ -163,7 +169,7 @@ export function NotificationBanner(props: INotificationBannerProps) { collapsibleHeight={collapsibleRef.current?.getBoundingClientRect().height ?? 0} className={props.className} onTransitionEnd={onTransitionEnd}> - <Content ref={contentRef}>{props.children}</Content> + <Content ref={contentRef}>{props.visible ? props.children : prevChildren.current}</Content> </Collapsible> ); } |
