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

fix(modal): [modal] empty str title should not be visible #1858

Merged
merged 3 commits into from
Aug 10, 2024

Conversation

gweesin
Copy link
Contributor

@gweesin gweesin commented Aug 7, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1856

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added a button option for displaying a modal without a title, allowing for more flexible user interactions.
    • Enhanced test coverage for modal title scenarios, including customizable titles and scenarios without titles.
  • Bug Fixes

    • Improved test stability by ensuring UI elements are fully rendered before assertions are made.
  • Refactor

    • Updated button click handlers for better descriptive naming and functionality.
  • Style

    • Conditional rendering of modal titles to improve user interface responsiveness.

Copy link

coderabbitai bot commented Aug 7, 2024

Walkthrough

The recent updates enhance the modal component's functionality and associated tests within the Vue framework. Key improvements include renaming functions for clarity, introducing new button functionalities, and modifying rendering logic to ensure elements only appear when necessary. Additionally, test cases have been expanded to cover scenarios involving custom and absence of titles, improving the robustness and flexibility of the modal presentation.

Changes

File Path Change Summary
examples/sites/demos/pc/app/modal/*.spec.ts Updated assertions and added steps in test cases to improve modal interaction and stability.
examples/sites/demos/pc/app/modal/title*.vue Renamed button handlers for clarity and added new button for title-less modals, enhancing UI options.
packages/vue/src/modal/src/*.vue Removed unused Button component and modified rendering logic for modal titles to prevent empty displays.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Modal
    participant Title

    User->>Modal: Clicks custom button
    Modal->>Title: Trigger customClick()
    Title-->>Modal: Show modal with custom title
    
    User->>Modal: Clicks no title button
    Modal->>Title: Trigger noTitleClick()
    Title-->>Modal: Show modal with empty title alert
Loading

🐰 In the meadow, changes bloom,
New buttons dance, dispelling gloom.
With titles bright or none at all,
Our modal sings, a joyful call!
Click and see the magic flow,
A rabbit's cheer, let improvements grow! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@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

Outside diff range, codebase verification and nitpick comments (1)
examples/sites/demos/pc/app/modal/basic-usage.spec.ts (1)

22-22: Inconsistent Class Name Update:

The class name for the success modal SVG element has not been consistently updated across the codebase. The old class name tiny-icon-success is still present in several files. Please update the following files to use the new class name tiny-modal-svg__success for consistency:

  • packages/renderless/src/wizard/vue.ts
  • packages/renderless/types/wizard.type.ts
  • examples/sites/demos/pc/app/progress/custom-status.vue
  • examples/sites/demos/pc/app/progress/custom-status-composition-api.vue
Analysis chain

Verify the updated class name for the success modal SVG element.

The change in class name from tiny-icon-success to tiny-modal-svg__success suggests a shift in the class naming convention or structure used in the modal component. Ensure that this change is consistent across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the updated class name for the success modal SVG element.

# Test: Search for the old and new class names. Expect: Only occurrences of the new class name.
rg --type css 'tiny-icon-success'
rg --type css 'tiny-modal-svg__success'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the updated class name for the success modal SVG element across various file types.

# Search for the old class name in CSS, HTML, JS, and TS files
rg 'tiny-icon-success' --type css --type html --type js --type ts

# Search for the new class name in CSS, HTML, JS, and TS files
rg 'tiny-modal-svg__success' --type css --type html --type js --type ts

Length of output: 1063

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4dbc4d3 and 797cc9b.

Files selected for processing (7)
  • examples/sites/demos/pc/app/modal/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/modal/lock-view.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/modal/title-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/modal/title.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/modal/title.vue (2 hunks)
  • packages/vue/src/modal/src/mobile.vue (2 hunks)
  • packages/vue/src/modal/src/pc.vue (1 hunks)
Additional comments not posted (14)
examples/sites/demos/pc/app/modal/title-composition-api.vue (4)

2-3: Ensure button click handlers are correctly defined.

The button click handlers customClick and noTitleClick are correctly defined and named. The labels "自定义标题" (Custom Title) and "无标题" (No Title) are appropriate for their respective functionalities.


5-5: Ensure imported components are used correctly.

The Button and Modal components are correctly imported from @opentiny/vue.


9-11: Ensure customClick function implements desired functionality.

The customClick function correctly displays a modal with the custom title "自定义标题".


13-15: Ensure noTitleClick function implements desired functionality.

The noTitleClick function correctly displays a modal with an empty title, implementing the desired functionality.

examples/sites/demos/pc/app/modal/title.vue (4)

2-3: Ensure button click handlers are correctly defined.

The button click handlers customClick and noTitleClick are correctly defined and named. The labels "自定义标题" (Custom Title) and "无标题" (No Title) are appropriate for their respective functionalities.


5-5: Ensure imported components are used correctly.

The Button and Modal components are correctly imported from @opentiny/vue.


14-16: Ensure customClick method implements desired functionality.

The customClick method correctly displays a modal with the custom title "自定义标题".


18-20: Ensure noTitleClick method implements desired functionality.

The noTitleClick method correctly displays a modal with an empty title, implementing the desired functionality.

examples/sites/demos/pc/app/modal/title.spec.ts (2)

3-11: Ensure renamed test case implements desired functionality.

The test case correctly verifies that the modal displays the custom title "自定义标题".


12-19: Ensure new test case implements desired functionality.

The new test case correctly verifies that the modal does not display a title when an empty title is provided.

examples/sites/demos/pc/app/modal/lock-view.spec.ts (1)

8-12: Ensure code example section is expanded before proceeding with test actions.

The added steps ensure that the code example section is expanded, which helps to stabilize the test by ensuring the UI is in the correct state before performing further actions. This is a good practice to avoid flaky tests.

packages/vue/src/modal/src/mobile.vue (2)

Line range hint 1-1:
Remove unused Button component.

The Button component is no longer directly used within this component's scope, which helps to reduce unnecessary dependencies.


108-116: Enhance conditional rendering for modal title.

The conditional rendering logic for the modal title ensures that it is only displayed when appropriate, improving the component's responsiveness to its props.

packages/vue/src/modal/src/pc.vue (1)

186-194: LGTM! The conditional rendering of the modal title is correctly implemented.

The change ensures that the span element for the modal title is only rendered if the title is not an empty string. This prevents empty titles from being displayed, which enhances the user interface.

@gweesin gweesin mentioned this pull request Aug 7, 2024
13 tasks
@gweesin
Copy link
Contributor Author

gweesin commented Aug 8, 2024 via email

@kagol kagol merged commit 57c4f99 into opentiny:dev Aug 10, 2024
3 of 5 checks passed
@gweesin gweesin deleted the fix/modal-title-empty branch March 10, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants