Skip to content

Commit feae16d

Browse files
committed
Add "persistent" prop to ipl-sidebar and ipl-dialog which disables closing the dialogs when clicking outside of them
1 parent ef07aab commit feae16d

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 3.6.0
2+
3+
- Add `persistent` prop to ipl-sidebar and ipl-dialog which disables closing the dialogs when clicking outside of them
4+
15
# 3.5.1
26

37
- Fix ipl-input with the large theme growing too wide in some cases

docs/examples/DialogExample.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ipl-dialog
88
v-model:is-open="dialogOpen"
99
style="width: 500px"
10+
:persistent="persistent"
1011
>
1112
<div class="width-capped-content">
1213
<ipl-space
@@ -31,13 +32,20 @@
3132
/>
3233
<!-- #endregion example -->
3334
</div>
35+
<div class="horizontal-layout">
36+
<ipl-checkbox
37+
v-model="persistent"
38+
label="Persistent"
39+
/>
40+
</div>
3441
</template>
3542

3643
<script setup lang="ts">
37-
import { IplButton, IplSpace, IplDialog } from '../../src';
44+
import { IplButton, IplSpace, IplDialog, IplCheckbox } from '../../src';
3845
import { ref } from 'vue';
3946
4047
const dialogOpen = ref(false);
48+
const persistent = ref(false);
4149
</script>
4250

4351
<style lang="scss">

docs/examples/SidebarExample.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
class="sidebar-example-layout"
55
>
66
<!-- #region example -->
7-
<ipl-sidebar v-model:is-open="sidebarOpen">
7+
<ipl-sidebar
8+
v-model:is-open="sidebarOpen"
9+
:persistent="persistent"
10+
>
811
<div class="width-capped-content">
912
<ipl-space
1013
color="light"
@@ -28,13 +31,20 @@
2831
/>
2932
<!-- #endregion example -->
3033
</div>
34+
<div class="horizontal-layout">
35+
<ipl-checkbox
36+
v-model="persistent"
37+
label="Persistent"
38+
/>
39+
</div>
3140
</template>
3241

3342
<script setup lang="ts">
34-
import { IplSidebar, IplButton, IplSpace } from '../../src';
43+
import { IplSidebar, IplButton, IplSpace, IplCheckbox } from '../../src';
3544
import { ref } from 'vue';
3645
3746
const sidebarOpen = ref(false);
47+
const persistent = ref(false);
3848
</script>
3949

4050
<style lang="scss">

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iplsplatoon/vue-components",
3-
"version": "3.5.1",
3+
"version": "3.6.0",
44
"description": "Vue components for internal Inkling Performance Labs utilities.",
55
"homepage": "https://github.com/IPLSplatoon/vue-components",
66
"repository": "https://github.com/IPLSplatoon/vue-components",

src/components/__tests__/iplSidebar.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ describe('IplSidebar', () => {
4444
expect(dialog.element.hasAttribute('inert')).toEqual(true);
4545
});
4646

47+
it('does not close the dialog when directly clicked and persistent', async () => {
48+
const wrapper = mount(IplSidebar, { props: { isOpen: true, persistent: true } });
49+
50+
const dialog = wrapper.get('dialog');
51+
const event = new Event('click');
52+
Object.defineProperty(event, 'target', { value: dialog.element });
53+
dialog.element.dispatchEvent(event);
54+
await flushPromises();
55+
56+
expect(dialog.element.close).not.toHaveBeenCalled();
57+
expect(dialog.element.hasAttribute('inert')).toEqual(false);
58+
});
59+
4760
it('does not close the dialog when clicking on a child of the dialog', async () => {
4861
const wrapper = mount(IplSidebar, { props: { isOpen: true } });
4962

src/components/iplDialog.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export default defineComponent({
2222
isOpen: {
2323
type: Boolean,
2424
required: true
25+
},
26+
persistent: {
27+
type: Boolean,
28+
default: false
2529
}
2630
},
2731
@@ -63,7 +67,9 @@ export default defineComponent({
6367
onClose();
6468
},
6569
onClick() {
66-
onClose();
70+
if (!props.persistent) {
71+
onClose();
72+
}
6773
}
6874
};
6975
}

src/components/iplSidebar.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export default defineComponent({
2222
isOpen: {
2323
type: Boolean,
2424
required: true
25+
},
26+
persistent: {
27+
type: Boolean,
28+
default: false
2529
}
2630
},
2731
@@ -63,7 +67,9 @@ export default defineComponent({
6367
onClose();
6468
},
6569
onClick() {
66-
onClose();
70+
if (!props.persistent) {
71+
onClose();
72+
}
6773
}
6874
};
6975
}

0 commit comments

Comments
 (0)