Skip to content
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

feat(ModalDialog): support IsCenter when set IsDraggable to true #4589

Merged
merged 8 commits into from
Nov 1, 2024

Conversation

ArgoZhang
Copy link
Collaborator

@ArgoZhang ArgoZhang commented Nov 1, 2024

support IsCenter when set IsDraggable to true

Summary of the changes (Less than 80 chars)

简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号

Description

fixes #4571

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

[是否影响老版本]

Risk

  • High
  • Medium
  • Low

[Justify the selection above]

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add support for centering modal dialogs when they are draggable and the IsCentered property is true. Update the default value of IsCentered to true and adjust unit tests to cover the new behavior.

New Features:

  • Add support for centering draggable modal dialogs when both IsDraggable and IsCentered properties are set to true.

Enhancements:

  • Set default value of IsCentered property to true for modal dialogs.

Tests:

  • Update unit tests to verify the behavior of draggable and centered modal dialogs.

Copy link

sourcery-ai bot commented Nov 1, 2024

Reviewer's Guide by Sourcery

This PR implements support for centering draggable modal dialogs by introducing a new CSS class 'is-draggable-center' and updating the JavaScript positioning logic. The implementation calculates the dialog's center position based on its dimensions and viewport size, then applies the position using CSS properties. The changes also include documentation improvements and updated unit tests.

Sequence diagram for modal dialog initialization

sequenceDiagram
    participant User
    participant ModalDialog
    participant JavaScript
    User->>ModalDialog: Open modal dialog
    ModalDialog->>JavaScript: init(id, invoke, shownCallback, closeCallback)
    JavaScript->>JavaScript: Check 'is-draggable-center' class
    alt is-draggable-center is present
        JavaScript->>JavaScript: Calculate center position
        JavaScript->>JavaScript: Apply CSS for centering
        JavaScript->>JavaScript: Remove 'is-draggable-center' class
    end
    JavaScript->>ModalDialog: Invoke shownCallback
Loading

Updated class diagram for ModalDialog component

classDiagram
    class ModalDialog {
        +bool IsCentered = true
        +bool IsDraggable
        +bool IsScrolling
        +bool ShowMaximizeButton
        +Size Size = Size.ExtraExtraLarge
        +FullScreenSize FullScreenSize
    }
    note for ModalDialog "Added 'is-draggable-center' class when IsCentered and IsDraggable are true"
Loading

File-Level Changes

Change Details Files
Implement centered positioning for draggable modal dialogs
  • Add new 'is-draggable-center' CSS class when both IsCentered and IsDraggable are true
  • Add JavaScript logic to calculate and set center position using viewport-relative units
  • Hide dialog initially with visibility:hidden to prevent position flickering
  • Remove 'is-draggable-center' class after positioning to allow dragging
src/BootstrapBlazor/Components/Modal/ModalDialog.razor.cs
src/BootstrapBlazor/Components/Modal/Modal.razor.js
src/BootstrapBlazor/Components/Modal/Modal.razor.scss
Improve component documentation and default values
  • Add default value annotations to property documentation
  • Set IsCentered default value to true
src/BootstrapBlazor/Components/Modal/ModalDialog.razor.cs
Update unit tests for new centering functionality
  • Add test case for is-draggable-center class presence
  • Add test case for is-draggable-center class removal when IsCentered is false
test/UnitTest/Components/ModalDialogTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#4571 Make modal dialog centered by default when both IsDraggable and IsCentered are set to true

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label Nov 1, 2024
@bb-auto bb-auto bot added this to the v9.0.0 milestone Nov 1, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Missing closing parenthesis in calc() expressions for margin calculations (link)

Overall Comments:

  • There's a syntax error in the JavaScript margin calculations - missing closing parentheses in the calc() functions. Please update to calc(50vw - ${width}px) and calc(50vh - ${height}px)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

src/BootstrapBlazor/Components/Modal/Modal.razor.js Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e8e7bbf) to head (2d72975).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #4589   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          621       621           
  Lines        27397     27398    +1     
  Branches      3921      3921           
=========================================
+ Hits         27397     27398    +1     

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

@ArgoZhang
Copy link
Collaborator Author

@sourcery-ai review

@ArgoZhang ArgoZhang enabled auto-merge (squash) November 1, 2024 07:21
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang merged commit d302b88 into main Nov 1, 2024
5 checks passed
@ArgoZhang ArgoZhang deleted the feat-dialog branch November 1, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(DialogService.ShowModal): IsDraggable 和 IsCentered 同时设置, 弹窗位置默认不居中
1 participant