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

Open Beginner friendly
#38,134 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
angular, javascript, typescript

Research direction

Start with the named directive at core-web/apps/dotcms-ui/src/app/portlets/dot-apps/components/dot-apps-configuration-detail/directives/dot-apps-code-block.directive.ts and trace how it creates and inserts DotCopyButtonComponent. Add or locate a unit test for that insertion path. Done means the inserted copy button has no autofocus attribute, the code still copies, and the acceptance criteria pass.

Written by the indexing model from the issue text.

Description

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)
Dominant language
Java
Stars
972
Forks
493
Avg merge
2d 12h
Merged PRs (30d)
237

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotCMS/core

All issues in dotCMS/core

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.