File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
packages/core/src/elements/dialog Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
99### Fixed
1010
11+ - Show dialog by default if ` twc-dialog ` element has the ` open ` attribute
1112- Nested dialog resets ` body ` padding
1213
1314## [ 0.3.0] - 2024-03-08
Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ describe('Dialog', async () => {
4949 expect ( document . body ) . not . to . have . style ( 'overflow' , 'hidden' ) ;
5050 } ) ;
5151
52+ it ( 'opens the dialog by default' , async ( ) => {
53+ const el = await fixture < DialogElement > ( html `
54+ < twc-dialog open >
55+ < dialog data-target ="twc-dialog.dialog "> Contents</ dialog >
56+ </ twc-dialog >
57+ ` ) ;
58+ const dialog = el . querySelector ( 'dialog' ) ! ;
59+
60+ assertDialogShown ( el , dialog ) ;
61+ expect ( document . body ) . to . have . style ( 'overflow' , 'hidden' ) ;
62+ } ) ;
63+
5264 it ( 'closes the dialog when clicked outside' , async ( ) => {
5365 const el = await fixture < DialogElement > ( html `
5466 < twc-dialog >
Original file line number Diff line number Diff line change @@ -19,6 +19,15 @@ export default class DialogElement extends ImpulseElement {
1919 this . handleClose = this . handleClose . bind ( this ) ;
2020 }
2121
22+ /**
23+ * Called when the element is connected to the DOM.
24+ */
25+ connected ( ) {
26+ if ( this . open ) {
27+ this . showModal ( ) ;
28+ }
29+ }
30+
2231 /**
2332 * Called when the element is removed from the DOM.
2433 */
You can’t perform that action at this time.
0 commit comments