Apps configuration page scrolls to the bottom on load when a field hint contains a code block

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
angular, javascript, typescript

调研方向

从指定的指令 core-web/apps/dotcms-ui/src/app/portlets/dot-apps/components/dot-apps-configuration-detail/directives/dot-apps-code-block.directive.ts 开始,追踪它如何创建并插入 DotCopyButtonComponent。为这条插入路径添加或查找一个单元测试。完成标准是:插入的复制按钮没有 autofocus 属性,代码仍能复制,并且满足验收标准。

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

描述

dotCMS : Analytics Team : Falcon
Problem Statement

When an App's configuration page loads, it scrolls down to the "Advanced Configuration (JSON)" field instead of staying at the top. Users land in the middle of the form and have to scroll back up to see the first fields. You can see it on the Content Analytics App.

The jump happens because the copy button inside the hint's code block gets focus by itself.

  • The dotAppsCodeBlocks directive turns each code block in a markdown hint into a box with a copy button (DotCopyButtonComponent). It renders that button outside the page with createComponent() and then inserts it.
  • PrimeNG's p-button adds autofocus="true" to its inner <button> whenever its autofocus input is not set. Its AutoFocus directive only removes the attribute when it gets exactly false, and an unset input arrives as undefined.
  • The browser focuses an element that is inserted into the page with autofocus already on it, and scrolls to it. Buttons that were already on the page don't trigger this. This one does, because it is inserted after being rendered.

This affects any App whose YAML puts a fenced code block in a field hint. The App YAML has no setting that controls this; the fix has to be in the frontend.

https://github.com/user-attachments/assets/67afb58c-9907-49c3-96e1-1bc5f36cc03a

Steps to Reproduce
  1. Go to Apps → Content Analytics and create a configuration for the System Host (/dotAdmin/#/apps/dotContentAnalytics-config/create/SYSTEM_HOST).
  2. Wait for the form to load.
  3. Notice that the page scrolls to "Advanced Configuration (JSON)".
  4. In DevTools, document.activeElement is the code block's copy button and has autofocus="true".
Acceptance Criteria
  • An App configuration page opens scrolled to the top, even when a field hint contains a code block.
  • Nothing in the hint's code block takes focus on page load.
  • The copy button in the code block still shows and copies the code.
  • A unit test covers that the copy button created by dotAppsCodeBlocks has no autofocus attribute when it is inserted.
dotCMS Version

main (introduced with the code block directive in #37897).

Severity

Low - Minor issue or cosmetic

Links
  • PR that added the directive: #37897
  • Directive: core-web/apps/dotcms-ui/src/app/portlets/dot-apps/components/dot-apps-configuration-detail/directives/dot-apps-code-block.directive.ts
  • App descriptor where it shows up: dotCMS/src/main/resources/apps/dotContentAnalytics-config.yml (the hint of advancedConfig)
主要语言
Java
星标
972
派生
493
平均合并
2 天 12 小时
30 天内合并 PR
237

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

dotCMS/core 的其他 Issue

查看 dotCMS/core 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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