Skip to content

Fix GoDAM 2.1 QA: non-PDF documents, audio overflow, stray media icon, Image rename - #2052

Closed
subodhr258 wants to merge 1 commit into
developfrom
fix/godam-2.1-qa-document-audio-icon
Closed

Fix GoDAM 2.1 QA: non-PDF documents, audio overflow, stray media icon, Image rename#2052
subodhr258 wants to merge 1 commit into
developfrom
fix/godam-2.1-qa-document-audio-icon

Conversation

@subodhr258

Copy link
Copy Markdown
Collaborator

Summary

Fixes five items from the GoDAM 2.1 QA tab plus one naming request from Slack. All were reproduced locally on Elementor 4.2.1 + WPBakery (js_composer) 9.0-beta.3 + WooCommerce before any code was written.

QA Issue Status
3, 6 Document looks blank in editor and on frontend Fixed
5 WPBakery page opens a download popup on refresh Fixed (same root cause as 3/6)
2 Audio block overlap in 3-column layout Fixed (was still reproducible, not already done)
7 Thumbnail displayed with separate icons Fixed
Slack "GoDAM Image" should read "Image" Done (core, Elementor, WPBakery)

QA 3, 5, 6: non-PDF documents

render.php emitted <object type="application/pdf"> pointing at whichever file was selected. Given a non-PDF the browser receives a type it cannot display, and the outcome splits by browser setting:

Browser state Result Reported as
PDF viewer enabled object collapses to 0px wide, inner content empty, and the <object> fallback is suppressed, so nothing at all is painted QA 3, 6 "looking blank"
PDF viewer disabled ("Download PDFs") the file is handed to the download manager QA 5 "download popup"

Evidence for QA 5: loading the page, with no click at all, wrote a file into ~/Downloads that was byte-identical to the test .docx (945 bytes, same zip entries, same body text).

PDF is the only format this block supports, so godam_is_supported_document() now gates output. The attachment's stored MIME type is authoritative, with the URL extension as a fallback for GoDAM tab media and URL-only documents.

The Gutenberg block, the [godam_document] shortcode (WPBakery) and the Elementor widget all render through the same render.php, so one guard covers all three front ends. Because rendering nothing would otherwise leave an author staring at an empty element, each editor now shows an "unsupported format" notice instead.

Also closed a hole in the block's own selection guard: it read if ( mime && mime !== 'application/pdf' ), so a missing MIME type passed straight through. It now tests for a positive PDF match and falls back to the extension.

QA 2: audio overlap in 3 columns

.godam-audio-player is a nowrap flex row with a 14px gap. __scrubber had flex: 1 1 auto but no min-width: 0, and input[type=range] carries a ~129px intrinsic min-content width, so the track refused to shrink:

56px play + 129px scrubber + 28px time + 28px gaps = 241px  in a 198px card body

The 43px excess pushed the non-shrinking __time label outside the card and 8.1px past the Elementor column. It only shows in 3-column layouts because wider columns have slack. Adding min-width: 0 shrinks the track to 86px and the row fits; the same file already does exactly this on __body and __play.

QA 7: stray icon over the thumbnail

Elementor absolutely centres .eicon-video-camera over the media area as its empty-state affordance and never hides it, because its own control only ever sets src on the preview <video>. Our control additionally sets poster from the GoDAM thumbnail, which left that icon stranded on top of a real image (measured 21x21, visible, dead centre over the 258x145 poster, with e-media-empty absent). The icon is now hidden while a poster is showing and kept for the empty state.

Worth noting for reviewers: the markup in class-godam-media.php is byte-identical to Elementor's native control and we add no CSS of our own, so this is only a bug for us because we are the ones adding a poster.

Rename

"GoDAM Image" to "Image" in core, Elementor and WPBakery, matching Video / Audio / Document / Video Gallery / Shoppable Video, which already drop the prefix inside the GoDAM category.

One behaviour change to be aware of: typing "godam" into WPBakery's Add Element search no longer matches this element, because no GoDAM element now carries "GoDAM" in its name. The GoDAM category tab remains the discovery path and lists all six correctly. Say the word if you would rather keep it searchable.

Testing

tests/php/DocumentSupportTest.php covers the new helper, which is the single gate protecting the embed: MIME beating a misleading .pdf URL, other media types, the URL fallback, query strings and fragments, a deleted attachment falling through to its URL, malformed input, and "pdf" appearing outside the extension.

OK (31 tests, 71 assertions)

Confirmed the tests can fail: mutating the helper to always return true fails all 7.

tests/bootstrap.php gains a wp_parse_url stub, WP time constants, and a require of custom-functions.php.

Manual verification steps

Needs both Elementor and WPBakery active, plus a non-PDF (for example a .docx) and a PDF in the media library.

  1. Frontend, non-PDF: put the .docx in a Document block, a [godam_document] shortcode and an Elementor Document widget. Each should render nothing at all, and no download should start on load or refresh. Check with the browser's PDF viewer both enabled and disabled (chrome://settings/content/pdfDocuments), since the old bug presented differently in each.
  2. Frontend, PDF (regression): same three surfaces with the PDF still embed and display normally.
  3. Gutenberg editor: the .docx block shows "Unsupported file format" with the file name instead of a blank embed. Selecting a non-PDF from the library shows the snackbar warning and does not attach.
  4. Elementor editor: the Document widget shows the "Unsupported file format" panel. A valid PDF is unaffected.
  5. WPBakery frontend editor: the Document element shows the unsupported notice. The backend editor still shows its normal parameter summary.
  6. QA 2: an Elementor 3-column section with a GoDAM Audio widget per column. The duration label stays inside each card at desktop, tablet and mobile widths, and in the editor canvas.
  7. QA 7: select a transcoded video with a thumbnail in an Elementor GoDAM Video widget. The Video File preview shows the thumbnail with no icon on top. Clearing the media brings the camera icon back.
  8. Rename: /godam in the Gutenberg inserter, the Elementor widget panel, and WPBakery's Add Element > GoDAM tab all read "Image".

Automation impact

New hooks for E2E:

  • godam-pdf-content-unsupported (Gutenberg canvas notice)
  • godam-document-elementor-unsupported (Elementor editor notice)
  • godam-document-unsupported (WPBakery front-end editor notice)

No existing data-test-id was renamed or removed. Existing document selectors are unchanged for PDFs; suites that assert on a rendered non-PDF document will now correctly find no output.

Copilot AI review requested due to automatic review settings July 29, 2026 11:49
Document block (QA 3, 5, 6)
render.php emitted `<object type="application/pdf">` for whatever file was
selected. Given a non-PDF the browser gets a type it cannot display, so it
either paints an empty box, suppressing the `<object>` fallback and leaving
nothing at all on screen, or hands the file to the download manager, which
starts a download on every page load. Reproduced both: a .docx rendered a
0px-wide object with no fallback, and merely loading the page wrote the file
into ~/Downloads without any click.

PDF is the only format the block supports, so add godam_is_supported_document()
and gate output on it. The shared render.php backs the block, the
[godam_document] shortcode and the Elementor widget, so one guard covers all
three front ends; each editor now shows an "unsupported format" notice instead
of a silently empty element. Also close a hole in the block's selection guard,
where a missing MIME type passed straight through.

Audio player (QA 2)
.godam-audio-player is a nowrap flex row, and the scrubber had flex:1 1 auto
without min-width:0. input[type=range] carries a ~129px intrinsic min-content
width, so the track refused to shrink. In a narrow card, such as a 3-column
layout, play + track + time then needed 241px in a 198px row and the
non-shrinking time label was pushed outside the card and the column. Matches
how __body and __play in the same file already handle it.

Elementor media control (QA 7)
Elementor centres .eicon-video-camera over the media area as its empty-state
affordance and never hides it, because its own control only ever sets `src`.
Ours also sets a poster, which left that icon stranded on top of the thumbnail.
Hide it while a poster is showing; keep it for the empty state.

Rename
"GoDAM Image" to "Image" in core, Elementor and WPBakery, matching the Video,
Audio, Document and Video Gallery labels already in the GoDAM category.

Tests
godam_is_supported_document() is the single gate protecting the embed, so cover
its edge cases: MIME beats a misleading .pdf URL, query strings and fragments,
a deleted attachment falling through to the URL, and "pdf" appearing outside the
extension.
@subodhr258
subodhr258 force-pushed the fix/godam-2.1-qa-document-audio-icon branch from c11dcd3 to 65e52ed Compare July 29, 2026 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes GoDAM 2.1 QA regressions around Document (non-PDF) rendering, Elementor preview UI quirks, and Audio layout overflow, while also renaming “GoDAM Image” to “Image” across editors/builders.

Changes:

  • Add godam_is_supported_document() gating to prevent non-PDF documents from rendering/triggering downloads, plus editor-side “unsupported format” notices.
  • Fix audio scrubber overflow in narrow (3-column) layouts via flexbox min-width adjustment.
  • Clean up Elementor media control preview (hide stray camera icon when poster is present) and apply “Image” rename across Gutenberg/Elementor/WPBakery.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/php/DocumentSupportTest.php Adds unit tests covering MIME-vs-URL PDF support decisions and edge cases.
tests/bootstrap.php Extends test stubs/constants and loads helper functions under test.
inc/helpers/custom-functions.php Introduces godam_is_supported_document() helper to gate PDF-only embedding.
inc/classes/wpbakery-elements/class-wpb-godam-image.php Renames WPBakery element label to “Image”.
inc/classes/shortcodes/class-godam-document.php Shows unsupported-format notice in WPBakery front-end editor; otherwise renders nothing for non-PDF.
inc/classes/elementor-widgets/class-godam-image.php Renames Elementor widget title to “Image”.
inc/classes/elementor-widgets/class-godam-document.php Adds Elementor editor/preview unsupported-format rendering for non-PDF documents.
assets/src/js/elementor/controls/godam-media.js Hides Elementor’s camera icon overlay when a poster thumbnail is present.
assets/src/css/godam-elementor-preview.scss Styles Elementor unsupported state alongside existing empty-state placeholders.
assets/src/css/_godam-audio-card.scss Fixes 3-column audio overlap by allowing the scrubber to shrink (min-width: 0).
assets/src/blocks/godam-pdf/style.scss Adds WPBakery front-end editor unsupported-format notice styling.
assets/src/blocks/godam-pdf/render.php Prevents non-PDF output at render-time by gating with the new helper.
assets/src/blocks/godam-pdf/editor.scss Adds Gutenberg editor-only unsupported-format notice styling.
assets/src/blocks/godam-pdf/edit.js Strengthens PDF validation, supports in-flight uploads, and adds editor-canvas unsupported notice.
assets/src/blocks/godam-image/block.json Renames Gutenberg block title to “Image”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +409 to +414
// ── Editor canvas: unsupported format ─────────────────────────────────────
const UnsupportedCanvas = (
<div className="godam-pdf-unsupported" data-test-id="godam-pdf-content-unsupported">
<span className="godam-pdf-unsupported__icon dashicons dashicons-media-document" />
<h3 className="godam-pdf-unsupported__title">
{ __( 'Unsupported file format', 'godam' ) }
Comment on lines +298 to +308
// Content saved before the format was validated (or added by URL) can still hold
// a non-PDF. The front end renders nothing for those, so flag it here rather than
// showing an <embed> that just paints blank.
// Only flag on positive evidence: a loaded attachment whose MIME is not PDF, or,
// for a URL-only document, a URL that is not a .pdf. Staying quiet while the
// attachment record is still loading avoids flashing the notice on a good PDF.
const isUnsupported = hasDocument && ! temporaryURL && (
id
? ( !! mimeType && 'application/pdf' !== mimeType )
: ! /\.pdf(?:[?#]|$)/i.test( src || '' )
);
Comment on lines +64 to +72
// PDF is the only supported format; render.php emits nothing for anything
// else. In WPBakery's front-end editor that would leave a silently empty
// element, so show the author why. Callers that own their own editor
// messaging (the Elementor widget) check before reaching this point.
if ( ! godam_is_supported_document( $atts['id'], $atts['src'] ) ) {
if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) {
// The notice is styled by the block's stylesheet, which is normally
// enqueued further down, so enqueue it here too since we return early.
wp_enqueue_style( 'godam-pdf-style' );
Comment on lines +192 to +198
// PDF is the only supported format. The shared render.php emits nothing for
// anything else, which would leave a silently empty widget, so flag it in
// the editor instead, where the author can act on it.
if ( ! godam_is_supported_document( isset( $document_file['id'] ) ? $document_file['id'] : 0, $document_file['url'] ) ) {
$this->render_unsupported_state();
return;
}
Comment on lines +48 to +53
public function test_attachment_mime_type_is_authoritative() {
$this->stub_mime( 'application/pdf' );
$this->assertTrue(
godam_is_supported_document( 201, 'https://example.com/report.pdf' ),
'A PDF attachment should be supported.'
);
@subodhr258 subodhr258 closed this Jul 29, 2026
@subodhr258
subodhr258 deleted the fix/godam-2.1-qa-document-audio-icon branch July 29, 2026 12:38
@subodhr258

Copy link
Copy Markdown
Collaborator Author

Superseded by #2053. The branch was renamed to fix/godam-2.1-qa-items (the old name read as "audio icon", which is not a thing in this change); GitHub closed this PR instead of retargeting it. Same commit, same diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants