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

モーダルを開いてるときにescキーを押したら閉じられるように #4121

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Changes from 2 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
8 changes: 8 additions & 0 deletions src/store/ui/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ const useModalStorePinia = defineStore('ui/modal', () => {
}
}

const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && shouldShowModal.value) {
popModal()
}
}

window.addEventListener('keydown', onKeyDown)
Copy link
Member

Choose a reason for hiding this comment

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

ざっとaddEventListenerのreferencesを見た感じ関数が再利用されてなければ無名関数を使っているところが多そうです
個人的にもそっちの方が好みなので余裕があれば修正してほしいです:pray:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

確かにそうですね、直します


return {
isOnInitialModalRoute,
isClearingModal,
Expand Down