Repository navigation
Open page feedback in a dialog from the API beta banner - #4867
Conversation
The banner's "let us know" link sent readers to a GitHub issue form, while every API page already has a feedback widget. Where page feedback runs, the link now opens that widget in a dialog and keeps the page URL. Elsewhere, and without script, it stays a link to the issue form. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| @await RenderPartialAsync(_Feedback.Create(new FeedbackModel | ||
| { | ||
| PageUrl = Model.CurrentNavigationItem.Url, | ||
| PageTitle = Model.Title, | ||
| ApiBase = Model.FrontendConfig.ApiBasePath, | ||
| Surface = FeedbackSurface.Api, | ||
| Id = dialogId | ||
| })) |
There was a problem hiding this comment.
Severity: P3 (Low)
Coordinate the two widgets' feedback state, not just their element IDs. Both implementations restore drafts using only the page URL, including the stored feedbackId. After a draft is restored, the dialog and bottom-of-page widgets therefore hold the same ID but independent state. Submitting details in one and then changing the reaction in the other sends a reaction-only PUT to that same ID, erasing the already-submitted reasons and comment. Share the controller/state between instances or give the dialog an independent draft and feedback identity.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| // A click on the backdrop lands on the dialog itself; the dialog has no padding, so nothing else does. | ||
| if ( | ||
| target instanceof HTMLDialogElement && | ||
| target.matches('.api-beta-feedback') | ||
| ) { | ||
| target.close() | ||
| return | ||
| } |
There was a problem hiding this comment.
Severity: P3 (Low)
The backdrop check closes the dialog on any click whose target is the <dialog>. When a pointer goes down on one element and comes up on another, the browser fires click on their nearest common ancestor. So if a reader drags to select text in the comment textarea (or a reason label) and lets go past the edge of the dialog, the target is the dialog and it closes mid-task. To fix this, only close when the pointerdown also landed on the dialog itself, or compare the click coordinates against dialog.getBoundingClientRect().
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
| target instanceof HTMLDialogElement && | ||
| target.matches('.api-beta-feedback') |
There was a problem hiding this comment.
Severity: P3 (Low)
The backdrop-close behaviour finds the dialog by its styling class (.api-beta-feedback). The Site rules say JavaScript binds to data-* attributes and ARIA, never to styling classes, so that CSS can rename or restyle classes without touching behaviour. This file runs in the design-system bundle. If a theme or CSS refactor renames the class, clicking the backdrop silently stops closing the dialog. Bind it to a data attribute on the <dialog> instead, for example data-api-beta-feedback, as the opener already does with data-api-beta-feedback-open.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4867/ Sample changed pages: |
The "let us know" link in the API beta banner now opens the page feedback widget in a dialog, instead of sending readers to a GitHub issue form. Where page feedback does not run, the link still goes to the issue form.
Affects: API reference, Site UI
Prompt summary: Reviewers asked that the beta banner reuse the feedback mechanism already on every API page, through a modal, instead of a link to a GitHub issue. This follows #4832, which added the banner.
Why
The banner points readers at a GitHub issue form. That asks for a GitHub account and sends the report to a different place than the thumbs-up and thumbs-down feedback on the same page. A reader who just noticed a problem has to leave the page to report it.
What
The link opens the feedback widget in a dialog
Where page feedback runs, "let us know" opens a dialog with the page's own feedback widget: Yes or No, then reasons, then an optional comment. It uses the
apireasons and the same request and index as the widget at the bottom of the page, so no backend changes. Escape, the close button and a click on the backdrop close it. The widget sends the URL of the page the reader is on, also after moving between pages.The issue form stays as the fallback
Where page feedback does not run, or the browser has no script or
<dialog>, the link is a plain link to the issue form with the page URL filled in. A click with a modifier key opens that form in a new tab, as for any link.prodhas noPAGE_FEEDBACKflag today, so it shows the plain link until the flag is on.Both layouts
The dialog holds the design-system widget when
NAVIGATION_PREVIEWis on and the<page-feedback>web component when it is off.ShowPageFeedbackonGlobalLayoutViewModelreplaces the rule that two feedback partials each repeated, and the banner reads it too.FeedbackModeltakes an optionalId, so a second widget on a page does not share element ids with the first.Out of scope: feedback from the dialog is not marked as coming from the banner. Telling it apart needs a new request field, an API mapping change and a new index version. Enabling
PAGE_FEEDBACKforprodinconfig/assembler.ymlis left to a separate change.Verify
Check on the preview
PAGE_FEEDBACKon.🤖 Generated with Claude Code