Skip to content

Collapse RichHtmlPreview warning + buttons after user picks a mode#150

Open
jamessi1989 wants to merge 1 commit into
gdcc:developfrom
jamessi1989:issue-149-richhtml-collapse-warning
Open

Collapse RichHtmlPreview warning + buttons after user picks a mode#150
jamessi1989 wants to merge 1 commit into
gdcc:developfrom
jamessi1989:issue-149-richhtml-collapse-warning

Conversation

@jamessi1989
Copy link
Copy Markdown

@jamessi1989 jamessi1989 commented May 12, 2026

Summary

Change

Two-character (well, two-call) edit — header.remove() is appended to each click handler. header is already in scope as a var declared a few lines earlier.

-                 .click(function(){console.log('Click');$('.preview').html(theData);})
+                 .click(function(){console.log('Click');$('.preview').html(theData);header.remove();})
...
-                 .click(function(){console.log('Click');$('.preview').html(filterXSS(theData,options));})
+                 .click(function(){console.log('Click');$('.preview').html(filterXSS(theData,options));header.remove();})

I intentionally kept this PR minimal: just the collapse fix. The shortened warning text and an optional "Switch view" toggle mentioned in the issue are deferred — happy to follow up in a separate PR if the maintainers want them.

Test plan

  • Upload an HTML file containing <script> or <head> to a Dataverse instance and open its preview pane.
  • Verify the warning header + both buttons appear before any click.
  • Click "Display With Rich Content" → verify the header disappears and the rich content renders alone.
  • Click "Display Without Rich Content" (fresh load) → verify the header disappears and the XSS-filtered content renders alone.
  • Upload an HTML file with no <script>/<head> and verify the previewer still renders directly with no warning (unchanged behaviour).

The Rich/Non-Rich choice header stayed pinned above the preview for
the rest of the session, consuming ~100-150px in already-cramped
embedded iframes. Once the user has clicked either button the
decision is made and the warning has served its purpose.

Remove the header element on either click. Applied in
previewers/betatest per CONTRIBUTING.md.

Fixes gdcc#149
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.

RichHtmlPreview: warning + buttons should collapse after the user makes a choice

2 participants