Skip to content

Replace all 4 instances of jBox-style modal dialog boxes with HTML dialog element #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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DavidAnson
Copy link
Contributor

@DavidAnson DavidAnson commented May 21, 2025

@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!

Summary by CodeRabbit

  • New Features

    • Introduced a new utility for initializing modal dialogs using native HTML dialog elements, providing a more consistent and accessible user experience.
    • Added a new localization entry for the "OSD Font Manager" dialog title.
  • Refactor

    • Replaced legacy modal dialogs with native HTML dialog elements for snippet preview, font manager, and calibration manager interfaces.
    • Updated layout and styling for dialogs and related components to improve appearance and usability.
    • Removed dependency on the "jBox" modal library.
  • Style

    • Enhanced dialog and content styling for a more modern and cohesive look across dialog-based interfaces.
  • Chores

    • Cleaned up unused imports and legacy modal initialization code.

Copy link
Contributor

coderabbitai bot commented May 21, 2025

Walkthrough

This update migrates modal dialogs from the third-party "jBox" library to native HTML <dialog> elements, introducing a utility function for dialog initialization and updating related JavaScript, HTML, and CSS. Several dialog containers in the UI are restructured, and associated styles and localization entries are added or adjusted accordingly.

Changes

File(s) Change Summary
locales/en/messages.json Added localization key osdSetupFontManagerTitle for the OSD Font Manager dialog title.
src/css/main.less Added .html-dialog and .html-dialog-content classes for dialog styling.
src/css/tabs/cli.less Changed textarea styling selector from .jBox-container to global textarea#preview; added box-sizing: border-box.
src/css/tabs/osd.less Refactored layout and spacing for font logo preview and presets; replaced some absolute positioning with flexbox and grid.
src/js/main.js Removed import of the "jbox" library.
src/js/tabs/cli.js Replaced "jBox" modal usage with initializeModalDialog; updated modal open/close logic and event handler placement.
src/js/tabs/osd.js Replaced "jBox" modal usage with initializeModalDialog for font manager; removed explicit modal destruction.
src/js/tabs/power.js Replaced "jBox" modal usage with initializeModalDialog for calibration dialogs; removed explicit modal destruction and content hiding.
src/js/utils/initializeModalDialog.js Added utility module to standardize dialog initialization using native HTML dialogs with localized titles and close buttons.
src/tabs/cli.html Changed snippet preview from hidden <div> to semantic <dialog> with updated structure and classes.
src/tabs/osd.html Changed font manager modal from hidden <div> to <dialog>; simplified internal layout and structure; removed inline styles.
src/tabs/power.html Changed calibration manager containers from <div> to <dialog> elements with updated structure and classes.
test/setup.js Removed import and global assignment of "jBox" in test setup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (Button/Trigger)
    participant initializeModalDialog (Utility)
    participant HTMLDialogElement

    User->>UI (Button/Trigger): Clicks to open modal
    UI (Button/Trigger)->>initializeModalDialog: Calls with selectors, title key, etc.
    initializeModalDialog->>HTMLDialogElement: Prepares dialog, sets title, binds close event
    initializeModalDialog-->>UI (Button/Trigger): Returns dialog element
    UI (Button/Trigger)->>HTMLDialogElement: Calls showModal()
    User->>HTMLDialogElement: Interacts and closes dialog
    HTMLDialogElement->>initializeModalDialog: Triggers close callback (if provided)
Loading

This diagram illustrates the new standardized dialog flow using the utility function and native HTML dialogs.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd8a291 and 4cedb41.

📒 Files selected for processing (1)
  • src/tabs/osd.html (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tabs/osd.html

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.

@haslinghuis
Copy link
Member

Is this not ready now ?

@DavidAnson
Copy link
Contributor Author

@haslinghuis I've migrated all four dialogs, but it needs a little bit more work. I've been busy, but might do some more tonight. In particular, I'd like to pull some of the styling into a common theme and the OSD dialog has a couple of elements in the wrong place right now. Interestingly, there appears to be a green-screen effect for the custom OSD image which is visible in my branch, but does not show up for me in the public version. I solved one or two similar things by updating CSS selectors and assume something similar needs to be done here. I figured I would try to restore the green effect if I could figure out what it was meant to look like. Here are my complete notes:

TODO:
Escape should run dialog onClose just like the close button does
Fix positioning of Select Font Presets and Open Font File positioning in OSD
Fix positioning of “Update all” message in OSD - Fix progressLabel position and layout
Move common dialog+container styles into common LESS file
Apply greenness correctly to OSD dialog?

@DavidAnson DavidAnson changed the title Prototype for using HTML's dialog element instead of jBox for modal dialogs (OSD tab) Replace all 4 instances of jBox-style modal dialog boxes with HTML dialog element Jun 21, 2025
@DavidAnson
Copy link
Contributor Author

@haslinghuis, this is ready for review! I’ve included the commit notes below. Reviewers, please be aware that all testing has been done with the Virtual device - test this with real hardware/input including font files and custom images!


Replace all 4 instances of jBox-style modal dialog boxes with HTML dialog element

Notes:

  • The Power & Battery (2), OSD, and CLI tabs have been updated accordingly
  • HTML default control behavior was used whereever possible
  • HTML indent for the dialog tag is deliberately off to minimize diff noise in GitHub
  • Layout is not 100% identical, but spiratually the same - in most cases no changes were needed
  • OSD’s Font Manager dialog didn’t transition cleanly, so includes some slight restyling
  • OSD Font Manager previously had a green background/color for the graphic - that “just works” now
  • Specific cleanup (i.e., calling destroy()) does not seem necessary and was removed
  • Removal of jBox from setup.js and global scope seems not to affect jBox tooltips
  • Replacement of single quotes with double in main.js was done automatically by Prettier

@DavidAnson DavidAnson marked this pull request as ready for review June 21, 2025 05:57
@DavidAnson
Copy link
Contributor Author

^^ Regarding the green color for custom images, I saw it in a Joshua Bardwell video from a few years ago which was a nice reassurance that it did used to work at some point in time. :)

Copy link
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: 2

🧹 Nitpick comments (4)
locales/en/messages.json (1)

5311-5314: Provide clearer context for translators and verify usage of the new key

The description field is quite generic; specifying "for the OSD Font Manager modal dialog" will give translators better context. Also, confirm that this key is actually referenced in the code to avoid dead entries.

Proposed diff:

  "osdSetupFontManagerTitle": {
      "message": "OSD Font Manager",
-     "description": "Dialog title"
+     "description": "Dialog title for the OSD Font Manager modal dialog"
  },

Verify usage with:

#!/bin/bash
# Search for occurrences of the new localization key
rg "osdSetupFontManagerTitle" -n .
src/css/tabs/cli.less (1)

78-89: Scope the preview textarea selector to prevent global leakage.

The global textarea#preview rule now applies everywhere rather than only within the CLI dialog, risking unintended side effects in other parts of the app. It’s safer to scope it under the CLI context (or the dialog wrapper), for example:

- textarea#preview {
+ .tab-cli textarea#preview {
    background-color: rgba(0, 0, 0, 0.75);
    width: 100%;
    resize: none;
    overflow-y: scroll;
    overflow-x: hidden;
    font-family: monospace;
    color: white;
    box-sizing: border-box;
    padding: 5px;
    margin-bottom: 5px;
}
src/css/tabs/osd.less (1)

5-13: Replace negative margin hack with flex-centering for .progressLabel.

Using margin-top: -22px is brittle and may break if content height or font-size changes. Instead, consider using a flex container or centering with relative positioning for more robust vertical alignment:

.tab-osd .info {
-   position: relative;
+   display: flex;
+   align-items: center;
    width: 100%;
    .progressLabel {
-       position: absolute;
-       width: 100%;
-       height: 26px;
-       margin-top: -22px;
+       width: 100%;
+       line-height: 26px; /* center text vertically */
        text-align: center;
        color: white;
        font-weight: bold;
        a { ... }
    }
}
src/js/utils/initializeModalDialog.js (1)

54-54: Consider using optional chaining for cleaner code.

The logical AND pattern can be simplified using optional chaining for better readability.

Apply this diff to use optional chaining:

-        onClose && onClose();
+        onClose?.();
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3052b32 and 300d876.

📒 Files selected for processing (13)
  • locales/en/messages.json (1 hunks)
  • src/css/main.less (1 hunks)
  • src/css/tabs/cli.less (1 hunks)
  • src/css/tabs/osd.less (3 hunks)
  • src/js/main.js (0 hunks)
  • src/js/tabs/cli.js (2 hunks)
  • src/js/tabs/osd.js (2 hunks)
  • src/js/tabs/power.js (2 hunks)
  • src/js/utils/initializeModalDialog.js (1 hunks)
  • src/tabs/cli.html (1 hunks)
  • src/tabs/osd.html (3 hunks)
  • src/tabs/power.html (3 hunks)
  • test/setup.js (0 hunks)
💤 Files with no reviewable changes (2)
  • src/js/main.js
  • test/setup.js
🧰 Additional context used
🪛 HTMLHint (1.5.0)
src/tabs/osd.html

[error] 155-155: Duplicate of attribute name [ class ] was found.

(attr-no-duplication)

🪛 Biome (1.9.4)
src/js/utils/initializeModalDialog.js

[error] 54-54: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (15)
src/css/tabs/osd.less (1)

365-368: Verify uniqueness of the #font-logo ID and consider switching to a class.

IDs must be unique across the document. If the font-logo block can appear in multiple contexts, convert #font-logo to a class (e.g., .font-logo) to avoid collision.

src/css/main.less (1)

44-50: New .html-dialog classes correctly standardize dialog styling.

The additions for .html-dialog and .html-dialog-content properly override padding and border colour without interfering with the default dialog styles. Looks good.

src/js/tabs/osd.js (2)

19-19: LGTM! Import statement follows established pattern.

The import of the initializeModalDialog utility function is correctly implemented and aligns with the PR's objective to standardize modal dialog handling across the application.


2764-2765: Excellent migration to native HTML dialog elements.

The replacement of jBox modal instantiation with the initializeModalDialog utility function is well-implemented. The parameters are appropriate and this change successfully achieves the PR's objective of migrating to native HTML dialog elements while maintaining functionality and improving accessibility.

src/tabs/cli.html (1)

16-27: LGTM! Clean migration to native dialog element.

The restructuring correctly converts the snippet preview from a hidden div to a semantic HTML dialog element while preserving all functionality and content. The addition of closedby="any" and appropriate CSS classes aligns with the new modal system.

src/tabs/osd.html (1)

154-202: Successful dialog migration with improved semantic structure.

The font manager dialog has been properly converted to use native HTML dialog elements. The content organization and styling maintain the existing functionality while improving accessibility through semantic markup.

src/js/tabs/cli.js (3)

15-15: Correct import for the new modal system.

The import of initializeModalDialog utility properly replaces the jBox dependency for modal dialog handling.


154-163: Proper migration from jBox to native dialog initialization.

The refactoring correctly uses the new initializeModalDialog utility and properly handles the event registration outside of the dialog creation callback. The method change from open() to showModal() aligns with native dialog API.


528-546: Appropriate removal of jBox-specific cleanup code.

The cleanup method correctly removes jBox modal destruction logic since native HTML dialogs are automatically managed by the browser and don't require explicit cleanup.

src/tabs/power.html (1)

200-263: Consistent and correct dialog element migration.

Both calibration manager dialogs have been properly converted to semantic HTML dialog elements with appropriate attributes and CSS classes. The structure maintains existing functionality while improving accessibility and standardizing modal behavior.

src/js/utils/initializeModalDialog.js (1)

41-64: Well-structured utility function for dialog initialization.

The function properly handles all aspects of modal dialog setup including title bar creation, event handling, and activation button binding. The scroll reset feature is a nice touch for user experience.

src/js/tabs/power.js (4)

9-9: LGTM: Clean import replacement

The import change from jBox to the new initializeModalDialog utility is consistent with the migration goals.


340-346: Verify the callback behavior for calibrationManager

The modal initialization looks correct, but please confirm the callback logic: () => calibrationconfirmed || TABS.power.initialize() will only call TABS.power.initialize() when calibrationconfirmed is false (using short-circuit evaluation). Is this the intended behavior for the close callback?


348-354: LGTM: Confirmation dialog migration

The calibrationManagerConfirmation dialog initialization is clean and the callback correctly closes the parent dialog.


543-545: LGTM: Simplified cleanup aligns with native dialogs

Removing explicit modal destruction from cleanup is appropriate since native HTML dialog elements don't require manual cleanup like jBox modals did.

Copy link
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: 2

🧹 Nitpick comments (2)
src/js/utils/initializeModalDialog.js (2)

54-54: Use optional chaining for cleaner code.

The static analysis tool correctly suggests using optional chaining instead of the logical AND operator.

Apply this diff to use optional chaining:

-        onClose && onClose();
+        onClose?.();

13-25: Consider extracting inline styles to CSS classes.

The extensive use of inline styles makes the code harder to maintain and doesn't follow separation of concerns best practices.

Consider moving these styles to CSS classes in the main stylesheet and referencing them here. This would improve maintainability and allow for easier theming adjustments.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 300d876 and 64212e1.

📒 Files selected for processing (2)
  • src/js/utils/initializeModalDialog.js (1 hunks)
  • src/tabs/osd.html (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tabs/osd.html
🧰 Additional context used
🪛 Biome (1.9.4)
src/js/utils/initializeModalDialog.js

[error] 54-54: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (1)
src/js/utils/initializeModalDialog.js (1)

41-64: Overall implementation looks solid.

The main function logic is well-structured and handles the core requirements for modal dialog initialization. The approach of using native HTML dialog elements is modern and accessible.

@haslinghuis
Copy link
Member

Please rebase on master to include latest changes to facilitate testing.

@DavidAnson
Copy link
Contributor Author

Please rebase on master to include latest changes to facilitate testing.

I'll do that tonight, but FYI I did so before converting from a draft PR and it looks like there are only four newer commits to the branch.

@haslinghuis
Copy link
Member

@DavidAnson yes asking as it changed MSP parameters

…alog element

Notes:
- The Power & Battery (2), OSD, and CLI tabs have been updated accordingly
- HTML default control behavior was used whereever possible
- HTML indent for the dialog tag is deliberately off to minimize diff noise in GitHub
- Layout is not 100% identical, but spiratually the same - in most cases no changes were needed
- OSD’s Font Manager dialog didn’t transition cleanly, so includes some slight restyling
- OSD Font Manager previously had a green background/color for the graphic - that “just works” now
- Specific cleanup (i.e., calling destroy()) does not seem necessary and was removed
- Removal of jBox from setup.js and global scope seems not to affect jBox tooltips
- Replacement of single quotes with double in main.js was done automatically by Prettier
@DavidAnson
Copy link
Contributor Author

@haslinghuis, rebased and updated!

Copy link
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

♻️ Duplicate comments (1)
src/js/utils/initializeModalDialog.js (1)

60-60: Add null safety for dialogContainerElement.

Based on previous discussion, while jQuery handles null selectors gracefully, dialogContainerElement could be undefined if dialog.children().first().get(0) returns no element, which would cause scroll(0, 0) to throw an error.

-        // Reset any previous scrolling
-        dialogContainerElement.scroll(0, 0);
+        // Reset any previous scrolling
+        dialogContainerElement?.scroll(0, 0);
🧹 Nitpick comments (1)
src/js/utils/initializeModalDialog.js (1)

54-54: Use optional chaining for cleaner code.

The static analysis tool correctly identified that this can be simplified using optional chaining.

-    dialogElement.addEventListener("close", () => {
-        onClose && onClose();
-    });
+    dialogElement.addEventListener("close", () => {
+        onClose?.();
+    });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64212e1 and f6cc337.

📒 Files selected for processing (13)
  • locales/en/messages.json (1 hunks)
  • src/css/main.less (1 hunks)
  • src/css/tabs/cli.less (1 hunks)
  • src/css/tabs/osd.less (3 hunks)
  • src/js/main.js (0 hunks)
  • src/js/tabs/cli.js (2 hunks)
  • src/js/tabs/osd.js (2 hunks)
  • src/js/tabs/power.js (2 hunks)
  • src/js/utils/initializeModalDialog.js (1 hunks)
  • src/tabs/cli.html (1 hunks)
  • src/tabs/osd.html (3 hunks)
  • src/tabs/power.html (3 hunks)
  • test/setup.js (0 hunks)
💤 Files with no reviewable changes (2)
  • src/js/main.js
  • test/setup.js
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/css/tabs/cli.less
  • src/js/tabs/power.js
  • src/tabs/power.html
  • src/tabs/cli.html
  • src/css/main.less
  • src/js/tabs/cli.js
  • src/js/tabs/osd.js
  • src/tabs/osd.html
  • src/css/tabs/osd.less
  • locales/en/messages.json
🧰 Additional context used
🧠 Learnings (1)
src/js/utils/initializeModalDialog.js (2)
Learnt from: DavidAnson
PR: betaflight/betaflight-configurator#4484
File: src/js/utils/initializeModalDialog.js:18-18
Timestamp: 2025-06-21T06:29:10.886Z
Learning: In the initializeModalDialog utility function, the `find("#dialogclose")` call is scoped to the specific `dialogTitleBar` jQuery object being created, not the entire DOM. This means multiple modal dialogs can safely use the same "dialogclose" ID because each find operation only searches within its own title bar instance.
Learnt from: DavidAnson
PR: betaflight/betaflight-configurator#4484
File: src/js/utils/initializeModalDialog.js:57-61
Timestamp: 2025-06-21T06:31:57.094Z
Learning: jQuery handles null and empty selectors gracefully by returning an empty jQuery object. Calling methods like `.on()` on empty jQuery objects is a no-op and doesn't throw errors, so null checks for jQuery selectors are often unnecessary.
🪛 Biome (1.9.4)
src/js/utils/initializeModalDialog.js

[error] 54-54: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (2)
src/js/utils/initializeModalDialog.js (2)

11-30: LGTM! Well-structured dialog title bar creation.

The function creates a clean, accessible title bar with proper localization and event handling. The scoped ID usage is safe as discussed in previous reviews.


41-64: Excellent migration from jBox to native dialogs.

This utility function provides a clean abstraction for initializing native HTML dialog elements, maintaining the functionality while leveraging browser-native behavior. The approach aligns well with the PR objectives of simplifying modal invocation and improving accessibility.

@haslinghuis
Copy link
Member

haslinghuis commented Jun 23, 2025

image

this button does not respond ?

image

@DavidAnson
Copy link
Contributor Author

Possibly if is hooked up via query and the selector changed/got broken. Will have a look tonight!

@DavidAnson
Copy link
Contributor Author

this button does not respond ?

@haslinghuis, this should be fixed now, sorry. It was an issue with overlapping content trying to center the progress text over the progress bar. I converted to CSS grid which handles the scenario better.

@nerdCopter
Copy link
Member

nerdCopter commented Jun 24, 2025

can this be taller to avoid scrollbars? (or is this outside of scope?)
image

@haslinghuis
Copy link
Member

@nerdCopter I knew you were going to ask that: #4484 (comment) 😛

@@ -151,7 +151,8 @@ <h1 class="tab_title">
</div>

<!-- Font Manager dialog -->
<div id="fontmanagercontent" style="display:none; width:720px;">
<dialog closedby="any" id="fontmanagerdialog" class="html-dialog" style="width: 750px;">
<div class="html-dialog-content" style="height: 430px; overflow-y: scroll;">
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps

Suggested change
<div class="html-dialog-content" style="height: 430px; overflow-y: scroll;">
<div class="html-dialog-content" style="height: 530px; overflow-y: scroll;">

image

Copy link
Member

Choose a reason for hiding this comment

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

Without scroll

Suggested change
<div class="html-dialog-content" style="height: 430px; overflow-y: scroll;">
<div class="html-dialog-content" style="height: 530px">

image

@DavidAnson
Copy link
Contributor Author

Haha, okay, will do. :) I think removing the height entirely will allow the dialog to size itself as in the other cases.

@DavidAnson
Copy link
Contributor Author

@haslinghuis / @nerdCopter No more default scroll bar for OSD Font Manager dialog. :)

@nerdCopter
Copy link
Member

nerdCopter commented Jun 25, 2025

interestingly i still see unusable scroll (Preview URL)
image

@DavidAnson
Copy link
Contributor Author

@nerdCopter, I left the overflow attribute in case someone had a short screen and needed to scroll. Some browsers hide the scroll bar in that case. I can remove the overflow attribute entirely.

… to avoid even a disabled scroll bar on some platforms/browsers (PR feedback).
Copy link
Contributor

Preview URL: https://4cedb416.betaflight-configurator.pages.dev

Copy link

@DavidAnson
Copy link
Contributor Author

@nerdCopter, that disabled scrollbar is browser/platform-dependent, I think. It was not present on Chrome/Chromebook, but it should be gone now based on the CSS change I just made.

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.

3 participants