-
Notifications
You must be signed in to change notification settings - Fork 333
feat(vue-renderless/drawer): add close-on-press-escape api #3900
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
Merged
zzcr
merged 1 commit into
opentiny:dev
from
IKEYCY:IKEYCY/feat-drawer-close-on-press-escape
Dec 16, 2025
+155
−4
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
examples/sites/demos/pc/app/drawer/close-on-press-escape-composition-api.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-button @click="openDrawer" type="primary"> 抽屉组件 </tiny-button> | ||
| <tiny-drawer | ||
| title="标题" | ||
| :visible="visible" | ||
| @update:visible="visible = $event" | ||
| @confirm="confirm" | ||
| :close-on-press-escape="true" | ||
| > | ||
| <div>内容区域</div> | ||
| </tiny-drawer> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { ref } from 'vue' | ||
| import { TinyDrawer, TinyButton } from '@opentiny/vue' | ||
| const visible = ref(false) | ||
| function openDrawer() { | ||
| visible.value = true | ||
| } | ||
| function confirm() { | ||
| visible.value = false | ||
| } | ||
| </script> |
19 changes: 19 additions & 0 deletions
19
examples/sites/demos/pc/app/drawer/close-on-press-escape.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { test, expect } from '@playwright/test' | ||
|
|
||
| test('按 Esc 键关闭 Drawer(close-on-press-escape)', async ({ page }) => { | ||
| page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
|
|
||
| await page.goto('drawer#close-on-press-escape') | ||
|
|
||
| const drawer = page.locator('.tiny-drawer__main') | ||
|
|
||
| // 打开 Drawer(用文本更稳定) | ||
| await page.getByText('抽屉组件').click() | ||
| await expect(drawer).toBeVisible() | ||
|
|
||
| // 按 Esc | ||
| await page.keyboard.press('Escape') | ||
|
|
||
| // Drawer 关闭 | ||
| await expect(drawer).toBeHidden() | ||
| }) |
38 changes: 38 additions & 0 deletions
38
examples/sites/demos/pc/app/drawer/close-on-press-escape.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-button @click="openDrawer" type="primary"> 抽屉组件 </tiny-button> | ||
| <tiny-drawer | ||
| title="标题" | ||
| :visible="visible" | ||
| @update:visible="visible = $event" | ||
| @confirm="confirm" | ||
| :close-on-press-escape="true" | ||
| > | ||
| <div>内容区域</div> | ||
| </tiny-drawer> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyDrawer, TinyButton } from '@opentiny/vue' | ||
| export default { | ||
| components: { | ||
| TinyDrawer, | ||
| TinyButton | ||
| }, | ||
| data() { | ||
| return { | ||
| visible: false | ||
| } | ||
| }, | ||
| methods: { | ||
| openDrawer() { | ||
| this.visible = true | ||
| }, | ||
| confirm() { | ||
| this.visible = false | ||
| } | ||
| } | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent
pcDemovalue format.The
pcDemovalue uses camelCase (closeOnPressEscape) while other props use kebab-case matching their demoId (e.g.,before-close,mask-closable). This may cause the demo link to not resolve correctly.📝 Committable suggestion
🤖 Prompt for AI Agents