Skip to content
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

Modal flickering on closeing #4451

Closed
DennyWanye opened this issue Jul 11, 2024 · 8 comments
Closed

Modal flickering on closeing #4451

DennyWanye opened this issue Jul 11, 2024 · 8 comments
Labels
question Question related to the library, not an issue

Comments

@DennyWanye
Copy link

Ask your Question

when I closing Modal, the Modal is flickering once. and then it will close.

modalIssue.mov
@DennyWanye DennyWanye added the question Question related to the library, not an issue label Jul 11, 2024
@DennyWanye
Copy link
Author

this is my modal code

import { Portal, TextInput, Text, Modal } from 'react-native-paper';
import { StyleSheet, SafeAreaView } from 'react-native';
import { ReactNode } from 'react';
import { useTheme } from 'react-native-paper';

type formItems = {
    label: string,
    value: string,
    setValue: Function,
}

interface PropsTagEditor {
    title: string,
    visible: boolean,
    formItems: Array<formItems>,
    submitFun: Function,
}

export default function UseEditModal(Props: PropsTagEditor): ReactNode {

    const { title, visible, formItems, submitFun } = Props
    const theme = useTheme();
    const containerStyle = { backgroundColor: theme.colors.background, padding: 20 };

    return (<Portal>
        <Modal visible={visible} onDismiss={() => submitFun()} contentContainerStyle={containerStyle} >
            <SafeAreaView>
                <Text>{title}</Text>
                {
                    formItems.map((item, index) => {
                        return (
                            <TextInput
                                key={index}
                                label={item.label}
                                value={item.value}
                                onChangeText={text => item.setValue(text)}
                                mode="outlined"
                                style={styles.tagInput}
                                multiline={true}
                            />
                        )
                    })
                }
            </SafeAreaView>
        </Modal>
    </Portal>)
}

const styles = StyleSheet.create({
    tagInput: {
        marginTop: 10,
    },
});

1 similar comment
@DennyWanye
Copy link
Author

this is my modal code

import { Portal, TextInput, Text, Modal } from 'react-native-paper';
import { StyleSheet, SafeAreaView } from 'react-native';
import { ReactNode } from 'react';
import { useTheme } from 'react-native-paper';

type formItems = {
    label: string,
    value: string,
    setValue: Function,
}

interface PropsTagEditor {
    title: string,
    visible: boolean,
    formItems: Array<formItems>,
    submitFun: Function,
}

export default function UseEditModal(Props: PropsTagEditor): ReactNode {

    const { title, visible, formItems, submitFun } = Props
    const theme = useTheme();
    const containerStyle = { backgroundColor: theme.colors.background, padding: 20 };

    return (<Portal>
        <Modal visible={visible} onDismiss={() => submitFun()} contentContainerStyle={containerStyle} >
            <SafeAreaView>
                <Text>{title}</Text>
                {
                    formItems.map((item, index) => {
                        return (
                            <TextInput
                                key={index}
                                label={item.label}
                                value={item.value}
                                onChangeText={text => item.setValue(text)}
                                mode="outlined"
                                style={styles.tagInput}
                                multiline={true}
                            />
                        )
                    })
                }
            </SafeAreaView>
        </Modal>
    </Portal>)
}

const styles = StyleSheet.create({
    tagInput: {
        marginTop: 10,
    },
});

@amanblog
Copy link

Hey @DennyWanye did you find a solution for this?

@scottboyd-ai
Copy link

Also experiencing this issue, would love a solution.

@bberos
Copy link

bberos commented Jan 20, 2025

Also with this problem, any solution?

@scottboyd-ai
Copy link

No solution that I've seen. I was seeing this on 5.12.5, but 5.13.1 is out now. I didn't see any commits that would suggest this is fixed, but you never know. I'll be trying an upgrade eventually, but if someone else can confirm that this either is or isn't happening on 5.13.1, it might help.

@bberos
Copy link

bberos commented Jan 21, 2025

Agreed, in the meantime what I did was to add a conditional in the modal for when it's visible and this way the flickering stopped, but the fade animation is gone.
Might help for the moment...

   <Portal>
      {visible ? (
	<Modal
            visible={visible}
     ...

@CalculusCoder
Copy link

I found a solution; you can check out the respective links. Go to your react native paper modal component in your package.json and within the hide modal callback, replace

if (visibleRef.current) {
    showModal();
} else {
    setRendered(false);
}

With this

 setRendered(false);

Solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question related to the library, not an issue
Projects
None yet
Development

No branches or pull requests

5 participants