GenericDialog registers an unload listener that has no effect

未关闭 适合新手
#2,772 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

阅读 lib/components/GenericDialog.vue,跟踪注册和移除 unload 监听器的对话框生命周期钩子。判断对话框是否应在导航前发出警告,还是应移除监听器;issue 提供了这两种选项。完成标准是处理无效的监听器及其违反 unload 策略的问题,并确保对话框打开时行为一致。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
19
派生
10
平均合并
17 小时 4 分钟
30 天内合并 PR
30

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud-libraries/nextcloud-dialogs 的其他 Issue

查看 nextcloud-libraries/nextcloud-dialogs 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。