Skip to content

Fix auto width issue with different label positions#2208

Merged
Crabcyborg merged 4 commits into
masterfrom
issue-5561-fix_auto_width_issue_with_custom_label
Jan 27, 2025
Merged

Fix auto width issue with different label positions#2208
Crabcyborg merged 4 commits into
masterfrom
issue-5561-fix_auto_width_issue_with_custom_label

Conversation

@AbdiTolesa
Copy link
Copy Markdown
Contributor

@AbdiTolesa AbdiTolesa commented Jan 8, 2025

Fix https://github.com/Strategy11/formidable-pro/issues/5561

Issues fixed:

  • Autowidth used with different label positions
  • Alignment of label when positioned right

Before:
image

After:
image

Test steps

  1. Create a form and add a dropdown and other fields you want to test to your form, probably as in the screenshot example.
  2. Go to each field's option and Advanced > Label Position to Right
  3. Check Auto Width option for the dropdown.
  4. Save and preview the form.
  5. Confirm that the issues mentioned in the checklist above are addressed.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 8, 2025

Walkthrough

The pull request introduces CSS modifications specifically targeting form element layouts within containers having the .with_frm_style class. The changes focus on adjusting the width of select elements in .frm_left_container and .frm_right_container to max-content, ensuring they dynamically expand to fit their content. Additionally, the primary label within .frm_right_container is configured to align to the right side of its container by setting its margin-left to auto.

Changes

File Change Summary
css/custom_theme.css.php Added CSS rules for form element layout and styling, specifically targeting .with_frm_style containers

Possibly related PRs

Suggested reviewers

  • Crabcyborg

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5de48eb and 047c6ef.

📒 Files selected for processing (1)
  • css/custom_theme.css.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • css/custom_theme.css.php
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Run PHP Syntax inspection (8.3)
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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 (2)
css/_single_theme.css.php (2)

103-106: LGTM! Consider adding a fallback for older browsers.

The use of width: max-content is a good solution for auto-sizing select elements. However, for better browser compatibility, consider adding a fallback for older browsers.

 .<?php echo esc_html( $style_class ); ?> .frm_left_container select.auto_width,
 .<?php echo esc_html( $style_class ); ?> .frm_right_container select.auto_width {
+  width: auto<?php echo esc_html( $important ); ?>;
   width: max-content<?php echo esc_html( $important ); ?>;
 }

103-111: Overall implementation looks good!

The changes effectively address the auto width issue with different label positions using clean, modern CSS properties. The implementation is well-structured and maintains consistency with the existing styling patterns.

Consider documenting these CSS rules in the project's style guide to ensure consistent usage across the codebase.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5730480 and 4912c7e.

📒 Files selected for processing (1)
  • css/_single_theme.css.php (1 hunks)
🔇 Additional comments (1)
css/_single_theme.css.php (1)

108-111: LGTM! Good use of margin-left: auto for alignment.

The CSS rule effectively handles the alignment of labels and select elements in right containers, which is consistent with the PR's objective to fix positioning issues.

Copy link
Copy Markdown
Contributor

@truongwp truongwp left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks @AbdiTolesa!

@truongwp truongwp requested a review from Crabcyborg January 17, 2025 16:41
Comment thread css/_single_theme.css.php Outdated
@AbdiTolesa AbdiTolesa requested a review from Crabcyborg January 20, 2025 18:08
Comment thread css/custom_theme.css.php Outdated
@AbdiTolesa AbdiTolesa requested a review from Crabcyborg January 22, 2025 12:58
Comment thread css/custom_theme.css.php Outdated
@AbdiTolesa AbdiTolesa requested a review from Crabcyborg January 23, 2025 07:10
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.82%. Comparing base (5ba7e63) to head (047c6ef).
Report is 207 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2208      +/-   ##
============================================
- Coverage     26.96%   26.82%   -0.14%     
- Complexity     8236     8320      +84     
============================================
  Files           127      129       +2     
  Lines         27285    27488     +203     
============================================
+ Hits           7358     7375      +17     
- Misses        19927    20113     +186     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg left a comment

Choose a reason for hiding this comment

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

This looks good now. I haven't tested it though.

I'll merge this once Laura has tested and approves it.

Thanks @AbdiTolesa and @truongwp!

🚀

Copy link
Copy Markdown
Contributor

@lauramekaj1 lauramekaj1 left a comment

Choose a reason for hiding this comment

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

@AbdiTolesa I tested this and verified as fixed. Thank you!

@Crabcyborg
Copy link
Copy Markdown
Contributor

Thank you Laura!

🙌

@Crabcyborg Crabcyborg merged commit 1f7f865 into master Jan 27, 2025
@Crabcyborg Crabcyborg deleted the issue-5561-fix_auto_width_issue_with_custom_label branch January 27, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants