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

why is <dialog> defaulted to display: block? #26264

Closed
cskinfill opened this issue Apr 11, 2018 · 2 comments
Closed

why is <dialog> defaulted to display: block? #26264

cskinfill opened this issue Apr 11, 2018 · 2 comments
Labels

Comments

@cskinfill
Copy link

See this line

article, aside, dialog, figcaption, figure, footer, header, hgroup, main, nav, section {

It seems that this is causing the contents of the <dialog>...</dialog> to be rendered when the page is loaded. If bootstrap is not used, it will hide the contents until myDialog.showModal() is called.

@twbs twbs deleted a comment from bak12 Apr 11, 2018
@patrickhlauke
Copy link
Member

Can you provide a working reduced test case showing where this is causing problems?

@cskinfill
Copy link
Author

cskinfill commented Apr 11, 2018

In the document below, if its loaded as is, the dialog box will be hidden and only appears when the button is clicked. If the stylesheet link is uncommented, the dialog box will appear when the page loads.

<!doctype html>
<html lang="en">
<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> -->
</head>
<body>
  <dialog id="dialogTest">
    This should not show at load-time!!!!
    <button id="closeDialog">Close</button>
  </dialog>
  <span>This should show</span>
  <button id="showDialogBtn">Show dialog</button>
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  <script>
  (function() {
    var showDialog = document.getElementById('showDialogBtn');
    var dialogToShow = document.getElementById('dialogTest');
    var closeDialog = document.getElementById('closeDialog');

    // Update button opens a modal dialog
    showDialog.addEventListener('click', function() {
      dialogToShow.showModal();
    });

    // Form cancel button closes the dialog box
    closeDialog.addEventListener('click', function() {
      dialogToShow.close();
    });
  })();
  </script>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants