GenericDialog registers an unload listener that has no effect

Đang mở Phù hợp với người mới
#2,772 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Đọc lib/components/GenericDialog.vue và theo dõi các hook vòng đời của hộp thoại dùng để đăng ký và gỡ listener unload. Quyết định xem hộp thoại có nên cảnh báo trước khi điều hướng hay nên gỡ listener; issue đưa ra cả hai lựa chọn. Hoàn tất khi listener không hiệu quả và vi phạm chính sách unload được xử lý, đồng thời hành vi nhất quán trong lúc hộp thoại đang mở.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Description

Moved from nextcloud/server#65093 (issues can't be transferred between organizations).

lib/components/GenericDialog.vue registers an unload listener while a generic dialog (e.g. getDialogBuilder() / the delete confirmation in Files) is open:

const handleUnload = () => `${props.name}: ${props.text}`
onMounted(() => window.addEventListener('unload', handleUnload))
onUnmounted(() => window.removeEventListener('unload', handleUnload))

The return value of an unload handler is ignored, so the listener has no effect. Chrome is phasing out unload and blocks it by default on more and more sites, which logs a violation every time such a dialog is opened:

[Violation] Permissions policy violation: unload is not allowed in this document.

It was probably meant to be a beforeunload handler that warns before leaving the page while a dialog is open.

Suggestion

Either switch to beforeunload with event.preventDefault() (if the warning is wanted) or remove the listener.

Reported for @nextcloud/dialogs 7.5.0 as used by Nextcloud 35; still present on main.

Ngôn ngữ chính
TypeScript
Star
19
Fork
10
Merge trung bình
17 giờ 4 phút
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nextcloud-libraries/nextcloud-dialogs

Tất cả issue của nextcloud-libraries/nextcloud-dialogs

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.