[Vue] Fix to prevent hover when clicking on sidebar toggle button

In component demo1/src/layouts/main-layout/sidebar/SidebarLogo.vue.

  1. On sidebar toggle element (element with id kt_app_sidebar_toggle) add attribute ref="toggleRef"

  2. Add a new property for the component, to pass sidebar element.

    props: {
    sidebarRef: {
    type: Object as PropType<htmlelement null>,
    required: true,

  3. Inside setup function add a new ref variable and onMouted function as shown below.

    const toggleRef = ref<htmlformelement null>(null);

    onMounted(() => {
    setTimeout(() => {
    const toggleObj = ToggleComponent.getInstance(
    ) as ToggleComponent | null;

    if (toggleObj === null) {

    // Add a class to prevent sidebar hover effect after toggle click
    toggleObj.on("kt.toggle.change", function () {
    // Set animation state

    // Wait till animation finishes
    setTimeout(function () {
    // Remove animation state
    }, 300);
    }, 1);

    return {

In component demo1/src/layouts/main-layout/sidebar/Sidebar.vue.

  1. Add attribute ref="sidebarRef" on sidebar element (element with id kt_app_sidebar).

  2. Inside setup function add a new ref variable and return this variable.

    const sidebarRef = ref<htmlformelement null>(null);

    return {

  3. Pass sidebar ref to SidebarLogo component.

    <ktsidebarlogo :sidebar-ref="sidebarRef"></ktsidebarlogo>

Text formatting options
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (0)

React Dev Vacancy

KeenThemes is looking for a Junior React or Vue developer to build awesome apps.
keenthemes mega bundle