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(canvas/render): fix edited page not refresh on children page, fix pageSection should not be able to drag,remove post css warning #1060

Conversation

rhlin
Copy link
Collaborator

@rhlin rhlin commented Jan 22, 2025

English | 简体中文

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)
  • Built its own designer, fully self-validated

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:

Background and solution

  1. 父页面编辑后保存, 直接切到子页面(这时候子页面重新获取父页面慢的情况下),会出现子页面用的还是老的父页面,并且在新的父页面到达之后并没有触发重新渲染, 这里改为等待清空并等待
  2. 页面的框不能被拖动,否则会报自己拖动到自己内部导致的 找不到parentNode问题
  3. 顺便消除了postcss没有指定css路径本地开发报warning

What is the current behavior?

见背景

Issue Number: N/A

What is the new behavior?

  1. 页面退出编辑后,对应的非激活页面数据置为空重新获取, 解决 【父页面编辑后,子页面下的父页面还是老内容问题】
  2. 拖动条件增加不能是页面框, 解决【拖动页面框导致报错和后续数据紊乱问题】
  3. 根据postcss的警告提示增加{ from: undefined} ,消除【开发态postcss警告waring信息】

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • Enhancements

    • Improved component rendering logic with more precise component type identification
    • Enhanced CSS processing with additional configuration options
    • Refined page component data management when switching active states
  • Technical Improvements

    • Updated draggable component behavior to respect specific component types
    • Optimized state management for page schemas and async data

Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request introduces modifications to several files in the canvas rendering system, focusing on enhancing component type handling and state management. The changes include adding a componentType property to the rootChildrenSchema, updating CSS processing options, modifying page data management when components become inactive, and refining the logic for determining draggable components based on their type.

Changes

File Change Summary
packages/canvas/render/src/canvas-function/custom-renderer.ts Added componentType: 'PageSection' to rootChildrenSchema
packages/canvas/render/src/material-function/handle-scoped-css.ts Updated postcss().process() to include { from: undefined } option
packages/canvas/render/src/material-function/page-getter.ts Added asyncData.value = null when component becomes inactive
packages/canvas/render/src/render.ts Modified getBindProps to destructure componentType and update draggable conditions

Sequence Diagram

sequenceDiagram
    participant Renderer as Custom Renderer
    participant PageGetter as Page Getter
    participant RenderLogic as Render Logic

    Renderer->>PageGetter: Monitor component active state
    alt Component becomes inactive
        PageGetter->>PageGetter: Clear async data
    end

    RenderLogic->>RenderLogic: Process component type
    RenderLogic->>RenderLogic: Determine draggability
Loading

Possibly related PRs

Suggested Labels

bug, enhancement

Suggested Reviewers

  • hexqi
  • chilingling

Poem

🐰 Rendering magic, type by type,
Components dance with newfound might,
Draggable rules, now precise and clear,
Canvas evolves without a fear!
Code hops forward, bright and light! 🎨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@rhlin rhlin changed the title Fix edited page not refresh on children page fix(canvas/render): fix edited page not refresh on children page, fix pageSection should not be albe to drag,remove post css warning Jan 22, 2025
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

🧹 Nitpick comments (2)
packages/canvas/render/src/material-function/page-getter.ts (1)

53-54: LGTM! Core fix for stale data issue

Setting asyncData.value = null when the page becomes inactive ensures that stale data is cleared, directly addressing the PR's main objective of fixing refresh issues on child pages.

Consider optimizing the update logic

The immediate call to updateSchema() after nullifying the data might be unnecessary since the data will be fetched again when the page becomes active.

 if (!activeValue) {
   asyncData.value = null
-  updateSchema()
 }
packages/canvas/render/src/render.ts (1)

Line range hint 126-129: Consider performance optimization for property deletion

The static analysis tool flagged the use of the delete operator. While valid in this context, consider using undefined assignment for better performance.

-  invalidity.forEach((prop) => delete bindProps[prop])
+  invalidity.forEach((prop) => { bindProps[prop] = undefined })
🧰 Tools
🪛 Biome (1.9.4)

[error] 123-123: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd8ae42 and 0c0f129.

📒 Files selected for processing (4)
  • packages/canvas/render/src/canvas-function/custom-renderer.ts (1 hunks)
  • packages/canvas/render/src/material-function/handle-scoped-css.ts (1 hunks)
  • packages/canvas/render/src/material-function/page-getter.ts (1 hunks)
  • packages/canvas/render/src/render.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/canvas/render/src/render.ts

[error] 123-123: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: push-check
🔇 Additional comments (4)
packages/canvas/render/src/material-function/handle-scoped-css.ts (1)

5-5: LGTM! PostCSS warning fix

Adding { from: undefined } is the correct way to suppress PostCSS source file warnings.

packages/canvas/render/src/canvas-function/custom-renderer.ts (1)

10-10: LGTM! Component type addition

Adding componentType: 'PageSection' correctly identifies the root container and prevents it from being draggable, which aligns with the PR objective to fix drag-and-drop related issues.

Let's verify that this component type is consistently used:

✅ Verification successful

✓ Component type usage is consistent

The componentType: 'PageSection' is correctly used as a unique identifier for the root container, working alongside other page-related component types like PageStart. No inconsistencies found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other PageSection type declarations to ensure consistency
rg "componentType.*PageSection" -g "!*.{json,md}"

Length of output: 147


Script:

#!/bin/bash
# Search for similar section/page component types
rg "componentType.*[Ss]ection|componentType.*[Pp]age" -g "!*.{json,md}"

# Search for PageSection in type definitions and interfaces
ast-grep --pattern 'interface $_ { $$$ PageSection $$$ }'
ast-grep --pattern 'type $_ = { $$$ PageSection $$$ }'

# Search for PageSection in test files
rg "PageSection" -g "*.test.{ts,tsx,js,jsx}"

Length of output: 15968

packages/canvas/render/src/render.ts (2)

85-85: LGTM! Added componentType to schema destructuring

Correctly extracts componentType for use in drag-and-drop logic.


123-125: LGTM! Improved drag-and-drop control

The condition !['PageStart', 'PageSection'].includes(componentType) correctly prevents dragging of page-level components, which aligns with the PR objective to fix drag-and-drop related issues.

🧰 Tools
🪛 Biome (1.9.4)

[error] 123-123: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

@hexqi hexqi added this to the v2.2.0 milestone Jan 23, 2025
@hexqi hexqi changed the title fix(canvas/render): fix edited page not refresh on children page, fix pageSection should not be albe to drag,remove post css warning fix(canvas/render): fix edited page not refresh on children page, fix pageSection should not be able to drag,remove post css warning Jan 23, 2025
@hexqi hexqi merged commit fe04e1b into opentiny:release/v2.2.0 Jan 23, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 25, 2025
14 tasks
hexqi pushed a commit to hexqi/tiny-engine that referenced this pull request Jan 25, 2025
… pageSection should not be able to drag,remove post css warning (opentiny#1060)
@coderabbitai coderabbitai bot mentioned this pull request Jan 26, 2025
14 tasks
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