-
Notifications
You must be signed in to change notification settings - Fork 144
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 Invalid HTML Structure to Prevent Vue Hydration Errors #475
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis update adjusts the HTML in the Testbench Panel by wrapping table row elements in a Changes
Suggested Reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for circuitverse ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
v0/src/components/Panels/Shared/InputGroups.vue (2)
21-22
: Consider moving type conversion to computed properties.While explicit
Number()
conversion in template bindings works, it's generally better to handle type conversion in computed properties for better reusability and testing.<template> <input - :min="Number(valueMin)" - :max="Number(valueMax)" + :min="minValue" + :max="maxValue" ... /> </template> <script setup lang="ts"> + import { computed } from 'vue'; ... + const minValue = computed(() => Number(props.valueMin)); + const maxValue = computed(() => Number(props.valueMax)); </script>
62-72
: Enhance type safety in value manipulation methods.The increase/decrease methods could benefit from stronger type safety and shared validation logic.
+ function validateValue(value: number): number { + const min = Number(props.valueMin); + const max = Number(props.valueMax); + return Math.min(Math.max(value, min), max); + } function increaseValue() { if (!inputRef.value) return; let value = Number(inputRef.value.value) || 0; const step = Number(props.stepSize) || 1; - const max = Number(props.valueMax); - - if (value + step <= max) { - value += step; - emit("update:propertyValue", value); - } + value = validateValue(value + step); + emit("update:propertyValue", value); } function decreaseValue() { if (!inputRef.value) return; let value = Number(inputRef.value.value) || 0; const step = Number(props.stepSize) || 1; - const min = Number(props.valueMin); - - if (value - step >= min) { - value -= step; - emit("update:propertyValue", value); - } + value = validateValue(value - step); + emit("update:propertyValue", value); }Also applies to: 74-84
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (2)
v0/src/components/Extra.vue
(1 hunks)v0/src/components/Panels/Shared/InputGroups.vue
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- v0/src/components/Extra.vue
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - circuitverse
- GitHub Check: Header rules - circuitverse
- GitHub Check: Pages changed - circuitverse
🔇 Additional comments (3)
v0/src/components/Panels/Shared/InputGroups.vue (3)
2-2
: LGTM! HTML structure fix implemented correctly.The replacement of
<p>
with<div>
resolves the invalid HTML structure issue mentioned in the PR objectives.
10-10
: LGTM! Event handler syntax improved.The simplified event handler syntax (
@click="decreaseValue"
instead of@click="decreaseValue()"
) follows Vue best practices by avoiding unnecessary method invocation syntax.Also applies to: 31-31
47-49
: LGTM! Improved prop type flexibility.The updated prop types now correctly accept both String and Number values, making the component more flexible while maintaining type safety through TypeScript.
@vedant-jain03 @Arnabdaz please review changes. |
There was a problem hiding this 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 (3)
v0/src/components/Panels/Shared/InputGroups.vue (3)
4-13
: Consider using more precise types and numeric defaults.While the union types
[String, Number]
provide flexibility, they might lead to type coercion issues. Consider:
- Using numeric defaults for numeric values
- Using a more reasonable max value to prevent precision issues
const props = defineProps({ propertyName: { type: String, default: "Property Name" }, propertyValue: { type: Number, default: 0 }, propertyValueType: { type: String, default: "number" }, - valueMin: { type: [String, Number], default: "0" }, - valueMax: { type: [String, Number], default: "100000000000000" }, - stepSize: { type: [String, Number], default: "1" }, + valueMin: { type: [String, Number], default: 0 }, + valueMax: { type: [String, Number], default: 1000000 }, + stepSize: { type: [String, Number], default: 1 }, propertyInputName: { type: String, default: "Property_Input_Name" }, propertyInputId: { type: String, default: "Property_Input_Id" }, });
15-16
: Enhance type safety for emits and refs.Consider adding TypeScript types for emitted events and ref value.
-const emit = defineEmits(["update:propertyValue"]); +const emit = defineEmits<{ + (e: 'update:propertyValue', value: number): void +}>();
37-59
: Consider consolidating validation logic.The increase/decrease methods could benefit from reusing the validation logic from
updateValue
.function increaseValue() { if (!inputRef.value) return; let value = Number(inputRef.value.value) || 0; const step = Number(props.stepSize) || 1; - const max = Number(props.valueMax); + const newValue = value + step; - if (value + step <= max) { - value += step; - emit("update:propertyValue", value); - } + // Reuse validation logic + const event = { target: { value: String(newValue) } }; + updateValue(event); } function decreaseValue() { if (!inputRef.value) return; let value = Number(inputRef.value.value) || 0; const step = Number(props.stepSize) || 1; - const min = Number(props.valueMin); + const newValue = value - step; - if (value - step >= min) { - value -= step; - emit("update:propertyValue", value); - } + // Reuse validation logic + const event = { target: { value: String(newValue) } }; + updateValue(event); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
v0/src/components/Panels/Shared/InputGroups.vue
(1 hunks)
🔇 Additional comments (2)
v0/src/components/Panels/Shared/InputGroups.vue (2)
1-3
: LGTM! Clean imports using Vue 3 Composition API.The imports are well-organized and follow Vue 3 best practices by explicitly importing required composition API utilities.
18-35
: Input validation implementation looks good!The implementation now properly validates input values and handles edge cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@Arnabdaz
There was a problem hiding this 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 (1)
.github/workflows/simulator-test.yml (1)
13-32
: Well-Structured Job and StepsThe job
run-simulator-tests
is clearly structured with the following logical steps:
- Checkout Repository using
actions/checkout@v4
- Setup Node.js with version 22 via
actions/setup-node@v4
- Install Dependencies using
npm ci
- Run Simulator Tests via
npm run test -- src/simulator/spec
Each step is clearly defined and in the correct order. As a good-to-have improvement, consider adding caching (for example, caching the npm modules) to potentially speed up subsequent runs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (1)
.github/workflows/simulator-test.yml
(1 hunks)
🔇 Additional comments (2)
.github/workflows/simulator-test.yml (2)
1-2
: Clear Workflow Name DefinedThe workflow is named "Simulator Tests," which clearly indicates its purpose in running simulator tests.
3-12
: Properly Defined Trigger EventsThe
on
block correctly specifies triggers for both push and pull_request events on themain
anddev
branches. This setup ensures that the workflow runs in the appropriate scenarios to catch issues early.
There was a problem hiding this 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 (3)
.github/workflows/tests.yml (3)
3-11
: Trigger Configuration and Trailing Whitespace CleanupThe "on" configuration correctly triggers the workflow on pushes and pull requests to the
main
branch. However, static analysis flagged a trailing whitespace on line 11. Please remove the extra spaces to comply with YAML style guidelines. For example:- - main␣␣ + - main🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 11-11: trailing spaces
(trailing-spaces)
13-16
: Job Definition ReviewThe job is properly defined with
runs-on: ubuntu-latest
for leveraging the latest Ubuntu runner. For reproducibility, consider pinning to a specific Ubuntu release if your project requires consistent environments.
29-31
: Simulator Test Execution and Failure HandlingThe command used for running simulator tests is:
npm run test -- src/simulator/spec || echo "Simulator tests failed"
Using
|| echo "Simulator tests failed"
may inadvertently mask failures by allowing the step to succeed even if tests fail. Please confirm if this behavior is intended. If failing tests should exit with a non-zero status to fail the workflow, consider removing the|| echo "Simulator tests failed"
portion, for example:- npm run test -- src/simulator/spec || echo "Simulator tests failed" + npm run test -- src/simulator/spec
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/tests.yml
(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/tests.yml
[error] 11-11: trailing spaces
(trailing-spaces)
🔇 Additional comments (4)
.github/workflows/tests.yml (4)
1-2
: Workflow Naming is ClearThe workflow is named "Simulator Tests," which clearly indicates its purpose for running simulator tests.
17-20
: Repository Checkout StepThe checkout step uses
actions/checkout@v4
, which is correctly implemented to obtain the repository code.
21-25
: Node.js Setup is CorrectThe setup for Node.js using
actions/setup-node@v4
withnode-version: 20.x
is properly configured. This ensures that the workflow uses a recent version of Node.js.
26-28
: Dependencies Installation StepThe step to install dependencies with
npm install
is standard and appropriately placed before running the tests.
Fixes ##473
Describe the changes you have made in this PR -
<tr>
as a child of :Before: You had a
<tr>
(table row) directly inside a<table>
, but possibly not inside a<tbody>, <thead>, or <tfoot>.
Fix: You wrapped the
<tr>
inside a<tbody>
, which is required by HTML specifications.<p>
issue:Before: You had a
<div>
inside a<p>
, which is invalid because<p>
cannot contain block-level elements likeFix: You likely replaced the
<p>
with a<span>
(which can contain inline elements) or moved the<div>
outside the<p>
.Screenshots of the changes (If any) -
Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.
Summary by CodeRabbit
Refactor
Tests