Skip to content

Prototype for using HTML's dialog element instead of jBox for modal dialogs (OSD tab) #4484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

DavidAnson
Copy link
Contributor

@haslinghuis, you asked me to look at removing jBox last week. Here's a first draft of replacing the OSD tab's jBox modal dialog with the HTML dialog element. Please have a look and give it a try and let me know what you think of this basic approach.

Notes:

  1. This isn't pixel-perfect, but it should be color-correct and +/- 1 pixel pretty much everywhere. It behaves the same for me in virtual connection mode. (The result message after clicking "Upload Font" shows up in the wrong place, I only noticed that a minute ago and doubt it's hard to address.)
  2. The HTML diff is misleading - I reused the existing HTML entirely as-is and just relocated it to the bottom of the file inside a dialog element, so there's very little change there or to convert.
  3. The two helper functions I added would live in a separate modal.js file, probably. The net result is that it's a little bit simpler to invoke this than the jBox modal. (Assuming there aren't weird gotchas with the other couple of modals in the project.)
  4. As I understand the docs, clicking outside the dialog should close the dialog but doesn't for me on Chrome or Safari - maybe that's something I've done wonky, I didn't spend a ton of time investigating. The default handling of Esc or clicking the close button works. As a browser-native element, tab stops and accessibility should work correctly by default.
  5. The title bar layout should use flexbox instead of float, but I was lazy in the prototype. :) The hit box for the close button would be easier/larger with that approach and probably not need the negative margin trick I used.

I think those are the high points. Please let me know your thoughts!

Copy link
Contributor

coderabbitai bot commented May 21, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

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.

@haslinghuis
Copy link
Member

@DavidAnson thank you. Some comments:

  1. Probably in gui.js or a new modal.js
  2. IMO not closing modal by clicking outside is an improvement.
  3. can we remove the scroll bar in the modal?

Before:
Screenshot from 2025-05-21 14-10-33

After:
image

@DavidAnson
Copy link
Contributor Author

Thank you for the feedback! (Your first two sections are blank, but I assume that’s because you had no comment on those points in my list.)

The scrollbar is present in my implementation because it is present in the current implementation. The height of the dialog is fixed and so the few elements at the bottom are hidden by default. If I remove the height restriction, I think it will automatically grow as necessary. But I will leave the overflow property so people with short screens/windows will still be able to get to everything.

As I recall, there are two or three other modal dialogs in the app. Would you rather see this PR go in just changing this one and then follow up with the others OR would you rather have a PR that touches all of them at once? I could argue in favor of either approach. :)

@haslinghuis
Copy link
Member

First two points are clear. Removing scrolling is a suggestion for improvement and perhaps should be done separate.
Would add cli and power tab to verify what is needed for a centralized modal.
Then if needed we can decide to extract these tabs in it's own PR.

@haslinghuis
Copy link
Member

@DavidAnson any updates :)

@DavidAnson
Copy link
Contributor Author

No, sorry, been unable to work on this for the past few days. I should have time this week.

Copy link

sonarqubecloud bot commented Jun 8, 2025

Copy link
Contributor

github-actions bot commented Jun 8, 2025

Preview URL: https://c58f3441.betaflight-configurator.pages.dev

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

Successfully merging this pull request may close these issues.

2 participants