Repository navigation
Extend the embed modal for generated API examples - #3588
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| PHP | Oct 19, 2026 10:03p.m. | Review ↗ | |
| JavaScript | Oct 19, 2026 10:03p.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
One blocker: the Copy icon is never hidden while an example loads or fails, so Copy can put "Generating script tag…" or the error text on the clipboard. The rest of the change works.
Checked on the PR branch (preview env, Lite at 1c19cd6):
frm_embed_modal_optionsadds a fourth card and getstype, objectId, objectKey, content. The three default cards still show.- A
loadExampleexample uses a textarea and shows the description. The labelformatches the field id on every row. - Loading shows "Generating script tag…". A resolved string fills the field. A rejected promise and an empty string both show the error text.
- Copy icon:
svg.hiddenreadstrueon all three loading/failed rows, but there is nohiddenattribute and the computeddisplayisblock(see the inline comment).
Not exercised: the real API add-on, Enter/Space on the cards by real key presses (read in source only), Copy on a successful example, Views, PHPUnit and Cypress (draft, CI skipped), and the code-review/security-review/simplify skills.
| element.append( copyIcon ); | ||
|
|
||
| if ( loadExample ) { | ||
| copyIcon.hidden = true; |
There was a problem hiding this comment.
Blocker: this does not hide the icon. getCopyIcon() returns an SVG made with createElementNS, and hidden is not a real property on SVG elements. The assignment only sets a plain JS property. In the preview env the icon had no hidden attribute and its computed display was block while loading, after a failure and after an empty result. A user can click Copy and copy "Generating script tag…" or the error message, which is the case the PR says it prevents.
Use style.display, which works on SVG, and clear it on success.
| copyIcon.hidden = true; | |
| copyIcon.style.display = 'none'; |
Then in loadEmbedExample() replace copyIcon.hidden = false; with:
copyIcon.style.display = '';There was a problem hiding this comment.
Approve at fae5306. The Copy icon is now actually hidden while an example loads or fails, so Copy can no longer put the placeholder or the error text on the clipboard. That was the one blocker at 1c19cd6.
Verified this round (preview env, Lite on this head, forms list embed modal, an example row added per state through the frmEmbedFormExamples filter, page-only)
- Pending, rejected and empty examples: the Copy icon computes
display: noneand has zero width (it wasdisplay: blockbefore). The field shows "Generating script tag…" or the error text. - A resolved example (1.5 s delay): the icon comes back (
display: block, 18px wide) and clicking it copies the script tag, not the placeholder. The two default rows (shortcode, PHP) are unchanged and show their icons. - The delta is two lines in
js/admin/embed.js:copyIcon.hidden = truebecomescopyIcon.style.display = 'none', and the reveal sets it back to'', so the stylesheet decides the shown state. Nothing else readscopyIcon.hidden.
Not exercised: a screenshot of the modal (the evidence above is computed style and size, not an image), the real API add-on, Enter/Space on the cards by real key presses, Views, PHPUnit and Cypress (draft, CI skipped), and the code-review/security-review/simplify skills. The rest of the PR is unchanged since my 1c19cd6 pass.

Add a
frm_embed_modal_optionsfilter so add-ons can add an embed choice with the selected form or View and its content panel. Manual embed examples now support descriptions and asynchronous generation, allowing the API add-on to fetch protected embed code before enabling Copy.Keep the existing three choices and static examples working. Add Enter/Space activation to option cards and associate example labels with their code fields.
This contains only the Lite integration needed by the API embed work. Token generation, encryption, HTML export, and AJAX submission stay in formidable-api.
Testing
git diff --checkpassed. This file is served directly, so no bundle rebuild is required.Manual verification