Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NcColorPicker): close popover on submit event #6336

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/components/NcColorPicker/NcColorPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
<template>
<div class="container1">
<NcButton @click="open = !open"> Click Me </NcButton>
<NcColorPicker :model-value="color" @update:model-value="updateColor" :shown.sync="open" @submit="open = false" v-slot="{ attrs }">
<NcColorPicker :model-value="color" @update:model-value="updateColor" :shown.sync="open" v-slot="{ attrs }">
<div v-bind="attrs" :style="{'background-color': color}" class="color1" />
</NcColorPicker>
</div>
Expand Down Expand Up @@ -150,6 +150,7 @@ export default {
<template #trigger="slotProps">
<slot v-bind="slotProps" />
</template>
<template #default="slotProps">
<div role="dialog"
class="color-picker"
aria-modal="true"
Expand Down Expand Up @@ -196,11 +197,12 @@ export default {
</template>
</NcButton>
<NcButton type="primary"
@click="handleConfirm">
@click="handleConfirm(slotProps.hide)">
{{ t('Choose') }}
</NcButton>
</div>
</div>
</template>
</NcPopover>
</template>

Expand Down Expand Up @@ -363,13 +365,14 @@ export default {

/**
* Submit a picked colour and close picker
* @param {Function} hideCallback callback to close popover
*/
handleConfirm() {
handleConfirm(hideCallback) {
/**
* Emits a hexadecimal string e.g. '#ffffff'
*/
this.$emit('submit', this.currentColor)
this.handleClose()
hideCallback()

this.advanced = false
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/NcPopover/NcPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/
</NcPopoverTriggerProvider>

<!-- This will be the content of the popover -->
<template #popper>
<slot />
<template #popper="slotProps">
<slot name="default" v-bind="slotProps" />
</template>
</Dropdown>
</template>
Expand Down
Loading