Skip to content

Conversation

@devzom
Copy link
Contributor

@devzom devzom commented Sep 26, 2025

πŸ”— Linked issue

Resolves #4985

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Drawer bug related closing by clicking on interactive elements like: input, switch etc when it's non-dismissible, based on the https://ui.nuxt.com/docs/components/drawer#with-interactive-background example

When dismissible: false, overlay: false, and modal: false, the drawer shouldn't allow interaction with background elements without closing unexpectedly.

Before Fix (Bug Behavior)

  1. Open drawer with dismissible: false, modal: false, overlay: false
  2. Click on background elements (buttons, inputs, selects, switches)
  3. ❌ Drawer closes unexpectedly

After Fix (Expected Behavior)

  1. Open drawer with dismissible: false, modal: false, overlay: false
  2. Click on background elements (buttons, inputs, selects, switches)
  3. Drawer remains open, background elements work normally
  4. Close button inside drawer works correctly
  5. Programmatic closing still functions

Probably root cause

The vaul-vue library has click-outside detection that triggers dismissal even when dismissible: false in certain configurations. The DrawerContent component receives pointer events from outside clicks that cause unwanted closure.

Solution (Event prevention)

Following the same pattern used in Modal.vue, Slideover.vue, and Popover.vue components:

  1. Event Handler Prevention: When dismissible: false, prevent specific outside interaction events on DrawerContent
  2. Targeted Prevention: Only prevent pointerDownOutside events to allow internal interactions
  3. Preserve Internal Functionality: Allow close buttons, programmatic closing, and all internal interactions

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@github-actions github-actions bot added the v4 #4488 label Sep 26, 2025
@devzom devzom force-pushed the 4985-fix-drawer-closing-on-element-click branch from 0de4022 to 8137cdc Compare September 26, 2025 22:04
@devzom devzom changed the title fix: non-dismissible drawer closing on interactive elements click, ex input fix(drawer): non-dismissible closing on interactive elements click, ex input Sep 26, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 26, 2025

npm i https://pkg.pr.new/@nuxt/ui@5085

commit: 1f217ed

@hasan-ozbey
Copy link

hasan-ozbey commented Sep 28, 2025

I believe somehow the overlay components are also affecting the open state of each other. When you trigger close one overlay component, it triggers the same for all overlay components within the context.

nevermind, it was a bug on my setup

@benjamincanac benjamincanac changed the title fix(drawer): non-dismissible closing on interactive elements click, ex input fix(Drawer): prevent unwanted close when dismissible is false Sep 29, 2025
Copy link
Member

@benjamincanac benjamincanac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😊

@benjamincanac benjamincanac merged commit 2abdc21 into nuxt:v4 Sep 29, 2025
15 checks passed
@devzom devzom deleted the 4985-fix-drawer-closing-on-element-click branch September 29, 2025 17:32
@devzom
Copy link
Contributor Author

devzom commented Sep 29, 2025

@benjamincanac glad to help 😊

benjamincanac added a commit that referenced this pull request Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing the drawer after clicking on template elements

3 participants