Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

data-kt-drawer Popup some times can't open


Guys, I have a question. In Angular, I'm using a data-kt-drawer popup, which is a right-side sliding popup. However, for some reason, when the project first loads and I click the button, the animation and the dimming effect on the page work, but the popup doesn't appear from the right side. Yet, when I refresh the page, the issue resolves, and the popup becomes visible.

I've configured all my module files to load on the login screen as soon as the project starts, but this hasn't fixed the issue either. Has anyone encountered this before? How can I solve this? I can't pinpoint the root cause because when the issue occurs, I try adding console.log statements in the code, but since the project refreshes, the popup starts working, and I lose track of the issue.

Can anyone help?

this is my popup html

<div
id="kt_drawer_transactiondetailmenu"
class="bg-body resize-body b"
data-kt-drawer="true"
data-kt-drawer-name="transactiondetailmenu"
data-kt-drawer-activate="true"
data-kt-drawer-overlay="true"
data-kt-drawer-direction="end"
data-kt-drawer-toggle="#kt_drawer_transactiondetailmenu_toggle"
data-kt-drawer-close="#kt_drawer_transactiondetailmenu_close"
#scrollableResizeDiv
[style.width.px]="resizeWidth"

>


This is the code that opens my popup:
<pre lang="html">
<a id="kt_drawer_transactiondetailmenu_toggle" (click)="openPopup()" href="javascript:;" class="btn btn-sm btn-icon btn-bg-light btn-active-color-primary shadow-sm aside-color aside-color transaction-page-step3">
<span [inlineSVG]=""./assets/media/icons/duotune/arrows/arr064.svg"" class="svg-icon svg-icon-2"></span>
</a>


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


Hi

Could you please try to add this at your component param?

changeDetection: ChangeDetectionStrategy.Default


@Component({
selector: "app-your-component",
templateUrl: "./your-component.html",
// No need to specify changeDetection if you want the default behavior
// changeDetection: ChangeDetectionStrategy.Default (this is implicit)
})
export class YourComponent {
// Your component logic
}


Thanks


It seems like the issue could be related to when the data-kt-drawer initialization occurs. The problem might be that the script initializing the popup runs before the DOM or Angular bindings are fully ready.

Here’s a potential fix:

  1. Ensure the data-kt-drawer plugin is properly initialized after the Angular view is loaded using AfterViewInit.
  2. Use a delay to reinitialize the drawer in case of race conditions. Here’s a link to the Metronic documentation for Drawers. Check if you're missing any required initialization steps!
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(