tiny-engine icon indicating copy to clipboard operation
tiny-engine copied to clipboard

Fix/element not found v2.8:Add condition for when element is null

Open betterdancing opened this issue 2 months ago • 1 comments

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] 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?

  • [x] 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

What is the current behavior?

elementId存在但是找不到对应的element元素,例如teleport 或者是 顶层是 fragment 的元素 Issue Number: N/A

What is the new behavior?

如果在elementId找不到对应的元素,则直接return默认的delay毫秒50ms

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

Summary by CodeRabbit

  • Bug Fixes
    • Updated UI timing: a consistent baseline delay is now applied when target elements are missing. When elements are present, that baseline is added before any transition delays, increasing total wait time in cases with non-zero transitions and removing the previous longer fallback. This changes the timing of subsequent UI refreshes.

betterdancing avatar Oct 31 '25 02:10 betterdancing

Walkthrough

getElementDurationTime now uses a 50ms baseline delay. If the target element is missing it returns 50ms immediately; if present, it starts at 50ms and adds computed CSS transition durations and delays to that baseline.

Changes

Cohort / File(s) Summary
Timing adjustment for element duration calculation
packages/canvas/container/src/container.ts
getElementDurationTime initializes delayTime at 50ms (was 0), returns 50ms early when element missing, and accumulates computed transition durations/delays on top of the 50ms baseline (removed previous 300ms fallback).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Review packages/canvas/container/src/container.ts for intended early-return behavior when element is missing.
  • Validate that adding a 50ms baseline and removing the 300ms fallback doesn't break timing assumptions in callers (selection/rect updates).
  • Check unit tests or UI flows that rely on specific delay values.

Poem

🐰 Fifty ticks beneath my paw,

a tiny pause before we draw.
Baseline set and stacks accrue,
I hop, I wait — then paint anew.
A softer beat for code and crew.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Fix/element not found v2.8:Add condition for when element is null" directly and specifically addresses the primary change described in the raw summary and PR objectives. The main modification is in the getElementDurationTime function to handle the case when a target element is missing by initializing and returning a default delay of 50ms. The title accurately captures this core fix by explicitly referencing "element not found" and "when element is null," which are the exact conditions being addressed. The title is concise, clear, and provides sufficient context without excessive detail or vague terminology.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e57bfafd5e8ef2b1c1bd8894bcb113e773067d4 and 624204e333f2bc5258d9065803e8d7ed32e276ea.

📒 Files selected for processing (1)
  • packages/canvas/container/src/container.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-01-14T08:45:57.032Z
Learnt from: rhlin
Repo: opentiny/tiny-engine PR: 1011
File: packages/canvas/render/src/application-function/global-state.ts:12-25
Timestamp: 2025-01-14T08:45:57.032Z
Learning: The code in `packages/canvas/render/src/application-function/global-state.ts` is migrated from an existing codebase and should be handled with care when making modifications.

Applied to files:

  • packages/canvas/container/src/container.ts
📚 Learning: 2025-01-14T08:44:09.485Z
Learnt from: rhlin
Repo: opentiny/tiny-engine PR: 1011
File: packages/canvas/render/src/canvas-function/controller.ts:1-7
Timestamp: 2025-01-14T08:44:09.485Z
Learning: Type safety improvements for the controller in `packages/canvas/render/src/canvas-function/controller.ts` should be deferred until the data structure is finalized.

Applied to files:

  • packages/canvas/container/src/container.ts
📚 Learning: 2025-01-14T06:59:23.602Z
Learnt from: rhlin
Repo: opentiny/tiny-engine PR: 1011
File: packages/canvas/render/src/page-block-function/methods.ts:9-21
Timestamp: 2025-01-14T06:59:23.602Z
Learning: The code in packages/canvas/render/src/page-block-function/methods.ts is migrated code that should not be modified during the migration phase. Error handling improvements can be addressed in future PRs.

Applied to files:

  • packages/canvas/container/src/container.ts
📚 Learning: 2025-01-14T06:55:14.457Z
Learnt from: rhlin
Repo: opentiny/tiny-engine PR: 1011
File: packages/canvas/render/src/canvas-function/design-mode.ts:6-13
Timestamp: 2025-01-14T06:55:14.457Z
Learning: The code in `packages/canvas/render/src/canvas-function/design-mode.ts` is migrated code that should be preserved in its current form during the migration process. Refactoring suggestions for type safety and state management improvements should be considered in future PRs.

Applied to files:

  • packages/canvas/container/src/container.ts
📚 Learning: 2025-01-14T06:50:21.158Z
Learnt from: rhlin
Repo: opentiny/tiny-engine PR: 1011
File: packages/canvas/render/src/data-function/parser.ts:191-195
Timestamp: 2025-01-14T06:50:21.158Z
Learning: The `newFn` function in `packages/canvas/render/src/data-function/parser.ts` has a known security issue with evaluating untrusted code through `data.value`. This was identified during code review but intentionally deferred as the original implementation was kept during code refactoring.

Applied to files:

  • packages/canvas/container/src/container.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: push-check

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

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 31 '25 02:10 coderabbitai[bot]