Skip to content

Add proceed anyway to small device message#2310

Merged
Crabcyborg merged 3 commits into
masterfrom
add_proceed_anyway_to_small_device_message
Apr 14, 2025
Merged

Add proceed anyway to small device message#2310
Crabcyborg merged 3 commits into
masterfrom
add_proceed_anyway_to_small_device_message

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Apr 10, 2025

Related comment https://github.com/Strategy11/formidable-pro/issues/4076#issuecomment-2790657289

The issue - Some users actually use the builder on their phones. So far I've seen this come up in 2 tickets, both on the day after the release.

Updated design https://www.figma.com/design/DQbZMgeNmJWkxOWYfHjDZX/Formidable-System?node-id=316-1642

This update adds a "Proceed Anyway" button to the small device message, instead of blocking their access to the pages. I save this as a user pref so it isn't shown again.

Screen Shot 2025-04-10 at 9 58 18 AM

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2025

Walkthrough

This pull request introduces a new static method small_screen_proceed in the FrmAppController, which handles AJAX requests for users on small screens. The method checks user permissions, verifies a nonce, updates a user option, and returns a JSON success response. An associated AJAX action is registered in FrmHooksController. The small-device message view now conditionally displays a warning and offers two action links. Additionally, CSS selectors are updated to depend on the presence of the small device message container, and JavaScript is added to handle the proceed button event and trigger an AJAX call.

Changes

File(s) Modified Change Summary
classes/controllers/FrmAppController.php
classes/controllers/FrmHooksController.php
Added a new small_screen_proceed method in FrmAppController and registered the AJAX action frm_small_screen_proceed in FrmHooksController.
classes/views/shared/small-device-message.php Introduced a conditional check based on user option to control the display of the small device warning; updated the message structure to include "Go Back" and "Proceed Anyway" links.
css/frm_admin.css Updated CSS selectors for #posts-filter to only apply when #frm_small_device_message_container is present.
js/formidable_admin.js Added an event listener for the #frm_small_screen_proceed_button that triggers an AJAX POST to execute the new small_screen_proceed functionality and remove the message container.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant JS
    participant WP_Handler
    participant Controller

    User->>JS: Clicks "Proceed Anyway" button
    JS->>WP_Handler: Sends AJAX POST request (frm_small_screen_proceed)
    WP_Handler->>Controller: Invoke FrmAppController::small_screen_proceed
    Controller->>Controller: Check permissions, verify nonce, update user option
    Controller-->>WP_Handler: Return JSON success response
    WP_Handler-->>JS: Transmit response
    JS->>JS: Remove small-device message container from UI
Loading

Possibly related PRs

Suggested reviewers

  • truongwp
  • lauramekaj1
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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/frm_admin.css (1)

9305-9308: CSS Selector Enhancement for Small Device UI

The new selectors using the :has() pseudo-class target both .toplevel_page_formidable:has(#frm_small_device_message_container) #posts-filter and .post-type-frm_display:has(#frm_small_device_message_container) #posts-filter to hide the posts filter element when the small device message container is present. This modification aligns well with the PR objective of providing a “Proceed Anyway” option by decluttering the interface on small devices.

Recommendations:

  • Browser Compatibility: Although the :has() pseudo-class is very powerful and expressive, its support in older browsers can be limited. Please verify that the target audience’s browsers fully support this feature or consider adding fallbacks or documentation to address potential compatibility issues.
  • Documentation: It might be beneficial to include a brief comment in this CSS block to explain the intended behavior for future maintainers.
classes/views/shared/small-device-message.php (1)

20-20: Implementation of dual-button interface works well, with a few enhancement opportunities.

The new "Proceed Anyway" button provides the functionality described in the PR objectives. The implementation correctly includes:

  • A unique ID for JavaScript interaction
  • Proper escaping for the "Go Back" URL
  • Clear, translatable button text

Some suggestions for improvement:

- <div><a href="<?php echo esc_url( admin_url() ); ?>" class="frm-button-primary"><?php esc_html_e( 'Go Back', 'formidable' ); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;<a id="frm_small_screen_proceed_button" href="#" class="frm-button-secondary"><?php esc_html_e( 'Proceed Anyway', 'formidable' ); ?></a></div>
+ <div class="frm-button-group">
+   <a href="<?php echo esc_url( admin_url() ); ?>" class="frm-button-primary"><?php esc_html_e( 'Go Back', 'formidable' ); ?></a>
+   <a id="frm_small_screen_proceed_button" href="#" class="frm-button-secondary" aria-label="<?php esc_attr_e( 'Proceed to Formidable Forms despite small screen warning', 'formidable' ); ?>"><?php esc_html_e( 'Proceed Anyway', 'formidable' ); ?></a>
+ </div>

This refactoring:

  1. Uses a container class for button spacing (rather than non-breaking spaces)
  2. Improves accessibility with an aria-label
  3. Makes the code more readable with better formatting
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f22f51 and caafab6.

📒 Files selected for processing (5)
  • classes/controllers/FrmAppController.php (1 hunks)
  • classes/controllers/FrmHooksController.php (1 hunks)
  • classes/views/shared/small-device-message.php (1 hunks)
  • css/frm_admin.css (1 hunks)
  • js/formidable_admin.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
classes/controllers/FrmAppController.php (1)
classes/helpers/FrmAppHelper.php (2)
  • FrmAppHelper (6-4474)
  • permission_check (2063-2071)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (5)
classes/controllers/FrmAppController.php (1)

1511-1523: LGTM - New functionality to allow users to proceed on small screens.

This new method handles the AJAX request when users click "Proceed Anyway" on small screens. The implementation is secure, checking permissions and verifying nonce before updating user preferences.

classes/controllers/FrmHooksController.php (1)

305-305: LGTM - Hook correctly registers the AJAX action.

The hook appropriately connects the AJAX action to the newly added small screen proceed method. This follows the pattern used for other AJAX actions in this file.

js/formidable_admin.js (1)

10642-10649: Well-implemented "Proceed Anyway" button functionality.

This implementation adds a click handler for the small screen proceed button that removes the warning message and sends an AJAX request to save the user's preference. The code follows good practices by checking if the element exists before attaching an event handler and using onClickPreventDefault to handle the click event properly.

classes/views/shared/small-device-message.php (2)

13-14: User preference check looks good!

The conditional check for whether a user has already chosen to ignore the small screen warning is properly implemented using WordPress's get_user_option() function.


23-24: Proper PHP structure

The PHP closing tag and conditional block closure are correctly placed, ensuring the entire message is conditionally displayed based on user preference.

Copy link
Copy Markdown
Contributor

@AbdiTolesa AbdiTolesa left a comment

Choose a reason for hiding this comment

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

Thanks @Crabcyborg! This looks good to me.

@Crabcyborg
Copy link
Copy Markdown
Contributor Author

Thank you Abdi!

@Crabcyborg Crabcyborg merged commit af1a7e1 into master Apr 14, 2025
15 of 16 checks passed
@Crabcyborg Crabcyborg deleted the add_proceed_anyway_to_small_device_message branch April 14, 2025 12:44
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.

2 participants