Skip to content

Conversation

SebastianWiz
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3081415206/89552

Summary

This PR fixes an issue where the CSS for the snippet wasn't being output when forms were loaded in popups or other contexts where wp_head had already fired.

Fix: The styles are now output inline with the form to ensure they apply in all scenarios.

Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

The pre-render filter now directly calls disable_auto_height_styles() instead of registering it via add_action('wp_head', ...). Other logic, including the invocation in gform_preview_footer and the CSS output within disable_auto_height_styles(), remains unchanged.

Changes

Cohort / File(s) Summary
Auto-height invocation path
gp-page-transitions/gppt-disable-auto-height.php
Replaced add_action('wp_head', 'disable_auto_height_styles') inside the pre-render filter with a direct call to disable_auto_height_styles(). No changes to disable_auto_height_styles() or gform_preview_footer logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant PR as Pre-render Filter
  participant WH as WP Head Hook
  participant CSS as disable_auto_height_styles()

  rect rgba(200,200,255,0.2)
  note over PR,WH: Previous flow
  PR->>WH: add_action('wp_head', disable_auto_height_styles)
  WH-->>CSS: Invokes on wp_head
  CSS-->>WH: Outputs CSS
  end

  rect rgba(200,255,200,0.2)
  note over PR,CSS: New flow
  PR->>CSS: Direct call during pre-render
  CSS-->>PR: Outputs CSS immediately
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly identifies the primary change—fixing styling output in all contexts for the specified file—using concise and specific language that matches the PR’s main modification.
Description Check ✅ Passed The description follows the required template by including both context with the ticket link and a clear summary of the fix, satisfying all mandatory sections from the repository template.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch seb/fix/auto-height-inline-styles

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

github-actions bot commented Oct 2, 2025

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 603cfb5

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
gp-page-transitions/gppt-disable-auto-height.php (1)

17-17: Consider adding deduplication to prevent duplicate style blocks.

The direct call ensures styles are output inline with the form, fixing the popup/late-loading issue. However, if the form renders multiple times on the same page (or if both gform_pre_render and gform_preview_footer fire), duplicate <style> blocks will be output.

Consider adding a static flag to prevent duplicate output:

 function disable_auto_height_styles() {
+	static $output = false;
+	if ( $output ) {
+		return;
+	}
+	$output = true;
+
 	?>
 	<style>
 	.gppt-has-page-transitions .swiper-slide {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 433b9b7 and 603cfb5.

📒 Files selected for processing (1)
  • gp-page-transitions/gppt-disable-auto-height.php (1 hunks)

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

Successfully merging this pull request may close these issues.

1 participant