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

Dialog: fix #6356 and implement #6357 #6358

Merged
merged 2 commits into from
Sep 10, 2024
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
13 changes: 13 additions & 0 deletions apps/showcase/doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -22911,6 +22911,19 @@
"returnType": "void",
"description": "Fired when a dialog gets unmaximized."
},
{
"name": "dragstart",
"parameters": [
{
"name": "event",
"optional": false,
"type": "Event",
"description": "Browser event."
}
],
"returnType": "void",
"description": "Fired when a dialog drag begins."
},
{
"name": "dragend",
"parameters": [
Expand Down
11 changes: 11 additions & 0 deletions packages/primevue/scripts/components/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ const DialogEvents = [
}
]
},
{
name: 'dragstart',
description: 'Fired when a dialog drag begins.',
arguments: [
{
name: 'event',
type: 'object',
description: 'Event Object'
}
]
},
{
name: 'dragend',
description: 'Fired when a dialog drag completes.',
Expand Down
5 changes: 5 additions & 0 deletions packages/primevue/src/dialog/Dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ export interface DialogEmitsOptions {
* @param {event} event - Browser event.
*/
unmaximize(event: Event): void;
/**
* Fired when a dialog drag begins.
* @param {event} event - Browser event.
*/
dragstart(event: Event): void;
/**
* Fired when a dialog drag completes.
* @param {event} event - Browser event.
Expand Down
8 changes: 7 additions & 1 deletion packages/primevue/src/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
name: 'Dialog',
extends: BaseDialog,
inheritAttrs: false,
emits: ['update:visible', 'show', 'hide', 'after-hide', 'maximize', 'unmaximize', 'dragend'],
emits: ['update:visible', 'show', 'hide', 'after-hide', 'maximize', 'unmaximize', 'dragstart', 'dragend'],
provide() {
return {
dialogRef: computed(() => this._instance)
Expand Down Expand Up @@ -163,6 +163,10 @@ export default {
if (this.modal) {
!this.isUnstyled && addClass(this.mask, 'p-overlay-mask-leave');
}

if (this.dragging && this.documentDragEndListener) {
this.documentDragEndListener();
}
},
onLeave() {
this.$emit('hide');
Expand Down Expand Up @@ -320,6 +324,8 @@ export default {
this.container.style.margin = '0';
document.body.setAttribute('data-p-unselectable-text', 'true');
!this.isUnstyled && addStyle(document.body, { 'user-select': 'none' });

this.$emit('dragstart', event);
}
},
bindGlobalListeners() {
Expand Down
Loading