Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
Semantic React Modal weird height behavior

Here is the problem I am having when using the semantic UI React modal: I do as shown on their website, but weirdly my Modal moves around like in this GIF of what is happening.

I have no idea how to fix this. Here is my code:

class Success extends React.Component {
  constructor () {
    super();
    this.closeModal = this.closeModal.bind(this)
    this.state = {
      Modalopen: true,
      Orders: "",
      urlparameter: qs.parse(location.search.replace(/^.*?\=/, ''))
    }
  }

  closeModal () {
    this.setState({Modalopen: false})
    this.props.history.pushState(null, "/")
  }

  render () {
    return (
      <Modal open={this.state.Modalopen}>
        <Modal.Header>Success!</Modal.Header>
        <Modal.Content image>
          <Image wrapped size='medium' src='http://semantic-ui.com/images/avatar2/large/rachel.png' />
          <Modal.Description>
            <Header>Thank you</Header>
            <p>bla bla bla</p>
            <Button color='green' onClick={this.closeModal} inverted>
              <Icon name='checkmark' /> Got it
            </Button>
          </Modal.Description>
        </Modal.Content>
      </Modal>
    );
  }
}

What might be causing this issue? Thank you.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I had the same problem today when trying to create a custom 'fullscreen' modal.

This is the line causing us trouble...

https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/modules/Modal/Modal.js#L255

If the modal height is greater than or equal to window.innerHeight, it adds the class scrolling which comes with a bunch of styles.

setPositionAndClassNames then appears to be called recursively on line 271, which is probably causing the weird looping behaviour.

Dirty fix

I'm adding margin-bottom: 1px to my modal to make sure it's a tiny bit less than window.innerHeight.

Long term solution

I'll open a PR into semantic-ui-react and see what they say...


UPDATE

I have a PR open at https://github.com/Semantic-Org/Semantic-UI-React/pull/3024 with a suggested fix.


UPDATE

That's merged and now part of Semantic UI React.

over 4 years ago · Santiago Trujillo Denunciar

0

In my case, it create Modal normally.

Here is the test code(ES5/webpack) :

[index.html]

<!DOCTYPE html>
<html lang="ko-KR">
<head>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/semantic.min.css"></link>
</head>
<body>
    <div id="wrap"></div>
    <script src="dist/app.js"></script>
</body>
</html>

[app.jsx]

var React = require('react');
var ReactDOM = require('react-dom');
var Semantic = require('semantic-ui-react');
var Button = Semantic.Button;
var Header = Semantic.Modal.Header;
var Image = Semantic.Image;
var Modal = Semantic.Modal;
var Icon = Semantic.Icon;

var IndexPage = React.createClass({
    getInitialState : function() {
        return {
            Modalopen: true,
            Orders: "",
            //urlparameter: qs.parse(location.search.replace(/^.*?\=/, ''))
        }
    },

    closeModal: function() {
        this.setState({Modalopen: false})
        //this.props.history.pushState(null, "/")
    },

    render : function () {
        return (
            <Modal open={this.state.Modalopen}>
                <Modal.Header>Success!</Modal.Header>
                <Modal.Content image>
                    <Image wrapped size='medium' src='http://semantic-ui.com/images/avatar2/large/rachel.png' />
                    <Modal.Description>
                        <Header>Thank you</Header>
                        <p>bla bla bla</p>
                        <Button color='green' inverted>
                            <Icon name='checkmark' /> Got it
                        </Button>
                    </Modal.Description>
                </Modal.Content>
            </Modal>
        );
    }
});

ReactDOM.render(<IndexPage/>, document.getElementById('wrap'));

Image of Result by the upper code

If you get the error continually, Please add the html/js files more detail with Codepen to test like your situation.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda