From b10e2c599455a0719a6dce51d442b804be505eb0 Mon Sep 17 00:00:00 2001 From: xavierchevalier Date: Thu, 11 Apr 2024 09:24:23 +0200 Subject: [PATCH] fix(sidebar): dismissable property should still be reactive after mount --- components/lib/sidebar/BaseSidebar.vue | 11 ++++++++++- components/lib/sidebar/Sidebar.spec.js | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/components/lib/sidebar/BaseSidebar.vue b/components/lib/sidebar/BaseSidebar.vue index f8acee993..773397a56 100644 --- a/components/lib/sidebar/BaseSidebar.vue +++ b/components/lib/sidebar/BaseSidebar.vue @@ -52,6 +52,15 @@ export default { return { $parentInstance: this }; - } + }, + watch: { + dismissable(newValue) { + if (newValue) { + this.bindOutsideClickListener(); + } else { + this.unbindOutsideClickListener(); + } + } + }, }; diff --git a/components/lib/sidebar/Sidebar.spec.js b/components/lib/sidebar/Sidebar.spec.js index 9a57a17db..2ad9090e9 100644 --- a/components/lib/sidebar/Sidebar.spec.js +++ b/components/lib/sidebar/Sidebar.spec.js @@ -119,4 +119,12 @@ describe('Sidebar.vue', () => { expect(wrapper.vm.containerVisible).toBeFalsy(); }); + + it('When component is mounted , dismissable property should still be reactive', async () => { + await wrapper.setProps({ dismissable: false, visible: true }); + + await wrapper.setProps({ dismissable: true }); + + expect(wrapper.vm.containerVisible).toBeTruthy(); + }); });