Fix front end message spacing issues#2429
Conversation
## Walkthrough
The update modifies the logic for processing form success messages, making autop formatting conditional based on message content and a new filter. Additionally, CSS rules for message paragraph spacing are adjusted to refine vertical margins within styled form message containers. The related test was updated to reflect the changed HTML structure of the success message output.
## Changes
| File(s) | Change Summary |
|-----------------------------------|--------------------------------------------------------------------------------------------------|
| classes/helpers/FrmFormsHelper.php | Updated `get_success_message` to conditionally apply autop formatting based on line breaks and a new filter hook. |
| css/custom_theme.css.php | Modified `.frm_message p` margin-bottom to 0 and added rule to remove margin-top from first paragraph. |
| tests/phpunit/forms/test_FrmFormsController.php | Updated test assertions to use `assertStringContainsString` and reflect success message without wrapping `<p>` tag. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant FrmFormsHelper
participant FrmAppHelper
participant WordPress
Note over FrmFormsHelper: get_success_message called
FrmFormsHelper->FrmFormsHelper: Check for line breaks in message
FrmFormsHelper->WordPress: Apply frm_wpautop_success_message filter
alt autop is true
FrmFormsHelper->FrmAppHelper: use_wpautop(message)
end
FrmFormsHelper->WordPress: do_shortcode(message)
FrmFormsHelper->User: Return formatted message in <div> |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
classes/helpers/FrmFormsHelper.php (1)
290-290: Update the version number in the @SInCE tag.The
@since x.xplaceholder should be replaced with the actual version number for this release.- * @since x.x + * @since 6.x.x
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
classes/helpers/FrmFormsHelper.php(1 hunks)css/custom_theme.css.php(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
classes/helpers/FrmFormsHelper.php (1)
classes/helpers/FrmAppHelper.php (2)
FrmAppHelper(6-4600)use_wpautop(2343-2349)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Cypress
- GitHub Check: Run PHP Syntax inspection (8.3)
- GitHub Check: Cypress
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (2)
css/custom_theme.css.php (1)
976-983: LGTM! CSS changes properly address message spacing issues.The margin adjustments for paragraphs within
.frm_messagecontainers are well-implemented:
- Removing bottom margin from all paragraphs prevents excessive spacing
- Removing top margin from the first paragraph ensures consistent spacing at the message top
These changes work effectively with the conditional autop logic in the PHP helper to provide consistent spacing regardless of whether paragraphs are auto-generated or manually written.
classes/helpers/FrmFormsHelper.php (1)
283-302: Good implementation of conditional autop formatting.The logic is well-designed:
- Only applies autop when line breaks are detected in the message
- Provides flexibility through the
frm_wpautop_success_messagefilter- Maintains proper processing order (autop before shortcodes)
This should effectively resolve the spacing issues while maintaining backward compatibility.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/phpunit/forms/test_FrmFormsController.php(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: Cypress
Fixes https://github.com/Strategy11/formidable-pro/issues/5901