question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal doesn't work properly

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request

Issue description

Current behavior: Modal won’t show up unless set isBackDropAllowed to true

Expected behavior: Modal should show up.

Steps to reproduce: Set up Modal to be like… ApplicationProvider > Layout > Modal but it’s not showing. Found out adding isBackDropAllowed will display it.

Related code:

export class HomeScreen extends React.Component {
  // ... incomplete code snippet
  styles = StyleSheet.create({
    container: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center',
      padding: 20
    },
    text: {
      marginVertical: 16,
    },
    modalBackdrop: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center',
      backgroundColor: '#000000AA',
      padding: 20,
      alignSelf: 'stretch'
    },
    modalInner: {
      backgroundColor: 'white',
      padding: 40,
      paddingTop: 32,
      paddingBottom: 16,
      borderRadius: 10,
    }
  });

  render() {
    return (
        <ApplicationProvider mapping={mapping} theme={lightTheme}>
          <Layout style={this.styles.container} level='4'>
            <Text style={this.styles.text} category='h5'>...</Text>
            <Input label={"Type in here"} multiline height={120}/>
            <Button size={"small"} style={{"marginTop":20}}>Send!</Button>
            <Modal
                visible={this.state.modalVisible}
                isBackDropAllowed
                style={this.styles.modalBackdrop}
            >
              <Layout>
                <View style={this.styles.modalInner}>
                  <Text style={{'textAlign':'center'}}>...</Text>
                  <Button size={"small"} style={{"marginTop":20}}>...</Button>
                  <Button appearance="ghost" size={"small"} style={{"marginTop":5,"paddingBottom":0}}>...</Button>
                </View>
              </Layout>
            </Modal>
          </Layout>
        </ApplicationProvider>
    )
  }
}

Other information:

OS, device, package version

OS: MacOS
Device: Expo + xCode Emulator

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
artiya4ucommented, Dec 7, 2019

“cannot press the “Hide Modal” button” Your live example on snack won’t work either. Please check my screen record

1reaction
artiya4ucommented, Dec 3, 2019

@artyorsh I’m using expo example project from “expo init my-new-project” with tabs and added react-native-ui-kitten v4.2.0 like in Add into existing project . Code in home screen like this:

import React from 'react';
import {
  StyleSheet,
} from 'react-native';

import {Button, Modal, Text, Layout} from 'react-native-ui-kitten';

export default class HomeScreen extends React.Component {
  state = {
    modalVisible: false,
  };

  setModalVisible = () => {
    const modalVisible = !this.state.modalVisible;
    this.setState({ modalVisible });
  };

  renderModalElement = () => {
    return (
      <Layout
        level='3'
        style={styles.modalContainer}>
        <Text>This is modal</Text>
        <Button onPress={this.setModalVisible}>Hide Modal</Button>
      </Layout>
    );
  };

  render() {
    return (
      <Layout style={styles.container}>
        <Button onPress={this.setModalVisible}>Show Modal</Button>
        <Modal
          visible={this.state.modalVisible}>
          {this.renderModalElement()}
        </Modal>
      </Layout>
    );
  }
}

HomeScreen.navigationOptions = {
  header: null,
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 16,
  },
  modalContainer: {
    width: 200,
    height: 200,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

My first attempt was a month ago (not sure the version) and it did not show at all. Now it shows but cannot press the “Hide Modal” button on the modal and it can press the tabs under the modal. Using allowBackdrop={true} will mitigate the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap modal not working at all - Stack Overflow
This was the issue for me as well. It seems the bootstrap team has not updated their own site with the new syntax....
Read more >
Modal not working - Material Design for Bootstrap
Hi, I'm having issues with modals in MCbootstrap. ... Topic: Modal not working ... If I open the file and remove display: none,...
Read more >
Bootstrap 5 modal not working (solved) on Codeply
Bootstrap modal not showing because the data- attributes should be data-bs-toggle and data-bs-target to open the modal Codeply example.
Read more >
scrollable doesn't work on modals with component as content
When using a component as the content of a modal rather than a template, with the scrollable option set to true, the modal...
Read more >
Modal · Bootstrap v4.6
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found