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: drawer component header does not take effect #4844

Merged
merged 1 commit into from
Nov 9, 2024
Merged

Conversation

anncwb
Copy link
Collaborator

@anncwb anncwb commented Nov 9, 2024

Description

fixed #4843

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced the EmptyIcon component for easier access in the public API.
  • Enhancements
    • Improved rendering logic in the SheetHeader component for better accessibility.
    • Streamlined pagination handling in the icon-picker component for improved clarity and functionality.
  • Bug Fixes
    • Removed the Package2 export, cleaning up unused icons.
  • Refactor
    • Simplified build configuration and export statements for better maintainability.

Copy link

changeset-bot bot commented Nov 9, 2024

⚠️ No Changeset found

Latest commit: 6d03aed

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Nov 9, 2024

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on simplifying the build configuration and modifying export statements. The build configuration has been streamlined to a single entry point. Export statements in various components have been adjusted, including the removal of certain exports and the addition of new ones. Additionally, the rendering logic in the drawer.vue component has been improved for better accessibility, and the pagination logic in icon-picker.vue has been updated for clarity and efficiency.

Changes

File Path Change Summary
packages/@core/base/icons/build.config.ts Updated entries from an array to a single string entry ['src/index'].
packages/@core/base/icons/src/index.ts Removed default export of EmptyIcon, added named exports from @iconify/vue, and exported type IconifyIcon as IconifyIconStructure.
packages/@core/base/icons/src/lucide.ts Removed export of Package2.
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue Replaced v-show with v-if for SheetHeader, added conditional rendering for accessibility, and updated interface to include optional drawerApi.
packages/effects/common-ui/src/components/icon-picker/icon-picker.vue Updated imports, redefined refTrigger, modified pagination logic, and improved template structure.
packages/effects/hooks/src/use-pagination.ts Renamed computed properties from getPaginationList to paginationList and getTotal to total.
packages/icons/src/index.ts Added new default export EmptyIcon from ./icons/empty-icon.vue.

Assessment against linked issues

Objective Addressed Explanation
Ensure the header can be completely hidden in the Drawer (#4843)
Fix the issue with the header property not being effective in the Drawer (#4839)

Possibly related issues

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • vince292007

Poem

In the code where icons play,
A new EmptyIcon found its way.
With drawers that hide, oh what a sight,
Accessibility shines, making it right.
Pagination flows like a gentle stream,
In the world of Vue, we chase our dream! 🐇✨


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>, 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 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.

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

🧹 Outside diff range and nitpick comments (6)
packages/effects/hooks/src/use-pagination.ts (2)

32-38: LGTM! Property naming improved.

The renaming of computed properties from getPaginationList and getTotal to paginationList and total respectively follows Vue's best practices for computed property naming conventions, making the code more idiomatic.

Consider adding JSDoc comments for these computed properties to maintain documentation consistency with the rest of the file:

+/**
+ * List of items for the current page
+ */
const paginationList = computed(() => {
  return pagination(unref(list), unref(currentPage), unref(pageSizeRef));
});

+/**
+ * Total number of items in the list
+ */
const total = computed(() => {
  return unref(list).length;
});

56-56: LGTM! Return structure updated correctly.

The return statement properly reflects the renamed properties, maintaining the hook's interface consistency.

Consider adding an explicit return type interface for better type safety and documentation:

+interface PaginationReturn {
+  setCurrentPage: (page: number) => void;
+  total: ComputedRef<number>;
+  setPageSize: (pageSize: number) => void;
+  paginationList: ComputedRef<T[]>;
+}

-return { setCurrentPage, total, setPageSize, paginationList };
+return { setCurrentPage, total, setPageSize, paginationList } satisfies PaginationReturn;
packages/effects/common-ui/src/components/icon-picker/icon-picker.vue (3)

41-41: Consider enhancing changeOpenState robustness

While the optional chaining is good, the function could be more defensive and provide feedback when the click fails.

Consider this enhancement:

 function changeOpenState() {
-  refTrigger.value?.click?.();
+  if (!refTrigger.value?.click) {
+    console.warn('Icon picker trigger element not found');
+    return;
+  }
+  refTrigger.value.click();
 }

Also applies to: 78-80


53-54: Enhance pagination accessibility

While the pagination logic works, consider these accessibility improvements:

  • Add ARIA labels for navigation
  • Ensure keyboard navigation works for all pagination controls

Consider these enhancements:

 <Pagination
   v-slot="{ page }"
   :items-per-page="36"
   :sibling-count="1"
   :total="total"
   show-edges
   size="small"
+  aria-label="Icon list navigation"
   @update:page="handlePageChange"
 >
   <PaginationList
     v-slot="{ items }"
     class="flex w-full items-center gap-1"
   >
-    <PaginationFirst class="size-5" />
-    <PaginationPrev class="size-5" />
+    <PaginationFirst class="size-5" aria-label="First page" />
+    <PaginationPrev class="size-5" aria-label="Previous page" />

Also applies to: 112-156


87-87: Extract magic numbers and improve maintainability

The template changes look good, but there are some improvements possible:

  1. The hardcoded pagination size (36) should be referenced from props
  2. The empty state handling is well implemented

Consider this enhancement:

 <Pagination
   v-slot="{ page }"
-  :items-per-page="36"
+  :items-per-page="pageSize"
   :sibling-count="1"

Also applies to: 91-91, 157-164

packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (1)

182-187: Consider enhancing the accessibility fallback content.

Good addition of accessibility support using VisuallyHidden! However, the empty SheetTitle and SheetDescription components could be more meaningful for screen readers.

Consider this improvement:

 <template v-else>
   <VisuallyHidden>
-    <SheetTitle />
-    <SheetDescription />
+    <SheetTitle>{{ title || $t('drawer.defaultTitle') }}</SheetTitle>
+    <SheetDescription>{{ description || $t('drawer.defaultDescription') }}</SheetDescription>
   </VisuallyHidden>
 </template>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8617d3d and 6d03aed.

📒 Files selected for processing (7)
  • packages/@core/base/icons/build.config.ts (1 hunks)
  • packages/@core/base/icons/src/index.ts (0 hunks)
  • packages/@core/base/icons/src/lucide.ts (0 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (2 hunks)
  • packages/effects/common-ui/src/components/icon-picker/icon-picker.vue (5 hunks)
  • packages/effects/hooks/src/use-pagination.ts (2 hunks)
  • packages/icons/src/index.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/@core/base/icons/src/index.ts
  • packages/@core/base/icons/src/lucide.ts
🔇 Additional comments (7)
packages/icons/src/index.ts (1)

2-2: Verify the existence of EmptyIcon component.

The export statement looks correct, but let's verify the existence of the EmptyIcon component.

✅ Verification successful

EmptyIcon component exists and is actively used in the codebase

The EmptyIcon component is:

  • Properly implemented as an SVG icon in packages/icons/src/icons/empty-icon.vue
  • Used in multiple components:
    • packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
    • packages/effects/common-ui/src/components/icon-picker/icon-picker.vue

The export statement is valid and the component is being utilized appropriately across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of empty-icon.vue and its usage

# Test 1: Check if empty-icon.vue exists
fd --type f "empty-icon.vue$" packages/icons/src/icons

# Test 2: Check if EmptyIcon is used in the codebase
rg "EmptyIcon" --type vue --type ts

Length of output: 160


Script:

#!/bin/bash
# Let's verify the EmptyIcon usage with a more reliable approach

# Check if empty-icon.vue exists and show its content
cat packages/icons/src/icons/empty-icon.vue

# Search for EmptyIcon usage without file type restrictions
rg "EmptyIcon"

Length of output: 1442

packages/@core/base/icons/build.config.ts (2)

Line range hint 1-8: Question: Is this change related to the drawer header fix?

This build configuration change appears unrelated to the PR's objective of fixing the drawer component header visibility issue (#4843). Could you please clarify why this change is included in this PR?

#!/bin/bash
# Check if there are any connections between this change and drawer components
echo "Checking for relationships between icons and drawer components:"
rg -l "drawer.*icon|icon.*drawer"

6-6: Verify build configuration changes impact.

The simplified build configuration might affect how icons are bundled and imported. Please ensure:

  1. Icon components are still properly processed
  2. TypeScript declarations are generated correctly
  3. Tree-shaking still works as expected
✅ Verification successful

Build configuration change is safe and follows package patterns

The simplified build configuration for the icons package is valid because:

  1. The entry point src/index.ts exists and exports all necessary icon-related functionality
  2. The configuration matches the pattern used in other packages (e.g., shared package)
  3. The build setup includes essential flags (clean: true, declaration: true) consistent with other packages
  4. The single entry point is sufficient as the index file properly re-exports all required components and utilities
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for icon imports and verify the new entry point exists
echo "Verifying src/index existence and content:"
find . -name "src" -type d -exec find {} -name "index.ts" \;

# Check for potential icon usage patterns that might be affected
echo "Checking icon usage patterns:"
rg -l "import.*from.*@core/base/icons"

Length of output: 459


Script:

#!/bin/bash
# Check if src/index.ts exists in the icons package
echo "Checking for src/index.ts in icons package:"
ls -la packages/@core/base/icons/src/index.ts 2>/dev/null || echo "File not found"

# Check the content of the build config file
echo -e "\nChecking build config content:"
cat packages/@core/base/icons/build.config.ts

# Look for any icon-related imports across the codebase
echo -e "\nChecking icon imports patterns:"
rg -A 2 "from ['\"](\.\.\/|@core\/base\/icons)" --type ts --type vue

# Check if there are other build configs for comparison
echo -e "\nChecking other build configs in the codebase:"
fd "build.config.ts" packages/@core

Length of output: 1411


Script:

#!/bin/bash
# Check other build configs for comparison
echo "Checking content of other build configs:"
for config in packages/@core/base/shared/build.config.ts packages/@core/ui-kit/layout-ui/build.config.ts; do
  echo -e "\n=== $config ==="
  cat "$config"
done

# Check the content of icons/src/index.ts
echo -e "\nChecking icons index.ts content:"
cat packages/@core/base/icons/src/index.ts

# Look for icon imports with fixed regex
echo -e "\nChecking icon import patterns:"
rg "from ['\"]@core/base/icons" --type ts --type vue -A 2

Length of output: 1832

packages/effects/hooks/src/use-pagination.ts (1)

Line range hint 32-56: Verify all usages of the pagination hook.

Let's ensure all components using this hook have been updated to use the new property names.

✅ Verification successful

No breaking changes found in usePagination hook usage

The verification shows that there's only one component using the usePagination hook - icon-picker.vue. This component is already using the correct property names from the hook's return value:

const { paginationList, total, setCurrentPage } = usePagination(

The search results confirm that there are no instances of old property names (getPaginationList, getTotal) in the codebase, and the component is correctly using the new property names (paginationList, total, setCurrentPage). All other matches in the search results are unrelated to this hook's usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all files that import and use the pagination hook
# to verify they've been updated to use the new property names

# Search for files importing the hook
echo "Files importing usePagination:"
rg -l "import.*usePagination.*from.*effects/hooks"

# Search for old property usage that might need updating
echo "\nChecking for old property names that need updating:"
rg "getPaginationList|getTotal" --type vue --type ts

Length of output: 323


Script:

#!/bin/bash
# Let's try a different approach to find usages

# First, find all possible imports of usePagination
echo "Files importing usePagination (broader search):"
rg -l "usePagination"

# Then look for actual usage patterns of the hook's return values
echo -e "\nChecking usage patterns:"
rg -A 2 "const.*=.*usePagination\(" 

# Also search for specific property access
echo -e "\nChecking property access:"
rg "paginationList|setCurrentPage|setPageSize|total"

Length of output: 6610

packages/effects/common-ui/src/components/icon-picker/icon-picker.vue (2)

2-5: LGTM! Clean import restructuring

The import changes improve code organization by:

  • Using the composition API's useTemplateRef
  • Replacing deprecated icons with new ones

Line range hint 1-166: Verify relationship with PR objectives

This icon picker component changes appear unrelated to the PR's main objective of fixing the drawer component header visibility issue (#4843).

Let's verify if this file is actually needed for the drawer header fix:

packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (1)

135-135: Excellent fix for header visibility issue!

Changing from v-show to v-if ensures complete removal of the header from the DOM when showHeader is false, effectively resolving the issue where the header couldn't be fully hidden. This is a more robust solution as it:

  1. Prevents any CSS-related visibility issues
  2. Improves performance for elements that don't frequently toggle
  3. Ensures proper cleanup of header-related DOM elements

@anncwb anncwb merged commit 4005023 into main Nov 9, 2024
14 checks passed
@anncwb anncwb deleted the bugfix/4843 branch November 9, 2024 07:53
@anncwb anncwb added the bug Something isn't working label Nov 9, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 27, 2024
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Vben Drawer无法完整隐藏header
1 participant