1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

fix: demo guide dialogs behavior (#3762)

Improves the dialogs behavior to address
https://linear.app/unleash/issue/2-1053/bug-when-big-dialog-is-open-if-you-click-on-a-step-the-flow-is-broken

Also prevents close on backdrop click for the welcome dialog.
This commit is contained in:
Nuno Góis 2023-05-12 18:58:06 +01:00 committed by GitHub
parent 1eaa619c9b
commit dabb6c00a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -87,6 +87,7 @@ export const Demo = ({ children }: IDemoProps): JSX.Element => {
<DemoBanner <DemoBanner
onPlans={() => { onPlans={() => {
closeGuide(); closeGuide();
setWelcomeOpen(false);
setPlansOpen(true); setPlansOpen(true);
@ -102,6 +103,7 @@ export const Demo = ({ children }: IDemoProps): JSX.Element => {
open={welcomeOpen} open={welcomeOpen}
onClose={() => { onClose={() => {
setWelcomeOpen(false); setWelcomeOpen(false);
setExpanded(false); setExpanded(false);
trackEvent('demo', { trackEvent('demo', {
@ -113,6 +115,7 @@ export const Demo = ({ children }: IDemoProps): JSX.Element => {
}} }}
onStart={() => { onStart={() => {
setWelcomeOpen(false); setWelcomeOpen(false);
onStart(); onStart();
trackEvent('demo', { trackEvent('demo', {
@ -152,6 +155,9 @@ export const Demo = ({ children }: IDemoProps): JSX.Element => {
setTopic(topic); setTopic(topic);
setStep(0); setStep(0);
setWelcomeOpen(false);
setPlansOpen(false);
trackEvent('demo', { trackEvent('demo', {
props: { props: {
eventType: 'start_topic', eventType: 'start_topic',
@ -162,6 +168,7 @@ export const Demo = ({ children }: IDemoProps): JSX.Element => {
topics={TOPICS} topics={TOPICS}
onWelcome={() => { onWelcome={() => {
closeGuide(); closeGuide();
setPlansOpen(false);
setWelcomeOpen(true); setWelcomeOpen(true);

View File

@ -31,16 +31,25 @@ const StyledHeader = styled(Typography)(({ theme }) => ({
interface IDemoDialogProps extends DialogProps { interface IDemoDialogProps extends DialogProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
preventCloseOnBackdropClick?: boolean;
children: React.ReactNode; children: React.ReactNode;
} }
export const DemoDialog = ({ export const DemoDialog = ({
open, open,
onClose, onClose,
preventCloseOnBackdropClick,
children, children,
...props ...props
}: IDemoDialogProps) => ( }: IDemoDialogProps) => (
<StyledDialog open={open} onClose={onClose} {...props}> <StyledDialog
open={open}
onClose={(_, r) => {
if (preventCloseOnBackdropClick && r === 'backdropClick') return;
onClose();
}}
{...props}
>
<StyledCloseButton aria-label="close" onClick={onClose}> <StyledCloseButton aria-label="close" onClick={onClose}>
<CloseIcon /> <CloseIcon />
</StyledCloseButton> </StyledCloseButton>

View File

@ -60,7 +60,7 @@ export const DemoDialogWelcome = ({
const { trackEvent } = usePlausibleTracker(); const { trackEvent } = usePlausibleTracker();
return ( return (
<DemoDialog open={open} onClose={onClose}> <DemoDialog open={open} onClose={onClose} preventCloseOnBackdropClick>
<DemoDialog.Header>Explore Unleash</DemoDialog.Header> <DemoDialog.Header>Explore Unleash</DemoDialog.Header>
<Typography color="textSecondary" sx={{ mt: 2 }}> <Typography color="textSecondary" sx={{ mt: 2 }}>
You can explore Unleash on your own, however for the best You can explore Unleash on your own, however for the best