# ๐Ÿ”ง Command Component Fix Design **Component**: `leptos-shadcn-command` **Priority**: ๐Ÿ”ด **CRITICAL** **Issues**: 68 compilation errors, type mismatches **Timeline**: 2-3 days ## ๐Ÿšจ Critical Issues ### **Type Mismatch Errors (68 total)** ```rust // Error pattern 1: String literal vs MaybeProp // โŒ &str // Expected: // โœ… MaybeProp // Error pattern 2: Boolean literal vs MaybeProp "Disabled Item" // โŒ bool // Expected: "Disabled Item" // โœ… MaybeProp // Error pattern 3: Option vs Callback on_value_change=Some(callback) // โŒ Option> // Expected: on_value_change=callback // โœ… Callback ``` ## ๐ŸŽฏ Fix Strategy ### **Phase 1: Prop Type Standardization** #### **1.1 String Props Fix** ```rust // Create helper macro for string literals macro_rules! prop_string { ($value:literal) => { $value.into() }; } // Usage in tests: ``` #### **1.2 Boolean Props Fix** ```rust // Create helper macro for boolean literals macro_rules! prop_bool { ($value:literal) => { $value.into() }; } // Usage in tests: ``` #### **1.3 Callback Props Fix** ```rust // Remove Option wrapper where not needed // Before: on_value_change=Some(callback) // After: on_value_change=callback ``` ### **Phase 2: Test Case Updates** #### **2.1 Update All Test Cases** ```rust // File: packages/leptos/command/src/tdd_tests.rs // Update all 68 error locations with proper type conversions // Example fix: #[test] fn test_command_basic_functionality() { view! { "Item 1" } } ``` #### **2.2 Create Type-Safe Test Helpers** ```rust // Add to test module: mod test_helpers { use leptos::prelude::*; pub fn string_prop(s: &str) -> MaybeProp { s.into() } pub fn bool_prop(b: bool) -> MaybeProp { b.into() } pub fn callback_prop(f: F) -> Callback where F: Fn(T) + 'static, { Callback::new(f) } } ``` ### **Phase 3: Component API Review** #### **3.1 Verify Component Definitions** ```rust // Check component prop definitions in: // packages/leptos/command/src/default.rs // packages/leptos/command/src/new_york.rs // Ensure all props use MaybeProp consistently: #[component] pub fn CommandInput( #[prop(into, optional)] placeholder: MaybeProp, #[prop(into, optional)] disabled: MaybeProp, // ... other props ) -> impl IntoView { // Implementation } ``` #### **3.2 Update Component Documentation** ```rust // Add prop type documentation: /// Command input component with type-safe props /// /// # Props /// - `placeholder`: MaybeProp - Input placeholder text /// - `disabled`: MaybeProp - Whether input is disabled /// - `on_value_change`: Callback - Value change callback ``` ## ๐Ÿ“‹ Implementation Steps ### **Step 1: Create Helper Macros (Day 1)** ```rust // Add to packages/leptos/command/src/lib.rs #[macro_export] macro_rules! prop_string { ($value:literal) => { $value.into() }; } #[macro_export] macro_rules! prop_bool { ($value:literal) => { $value.into() }; } ``` ### **Step 2: Fix Test Cases (Day 2)** ```bash # Fix all 68 errors in tdd_tests.rs # Use find/replace with regex patterns: # Find: placeholder="([^"]*)" # Replace: placeholder=prop_string!("$1") # Find: disabled=([^>]*) # Replace: disabled=prop_bool!($1) ``` ### **Step 3: Verify and Test (Day 3)** ```bash # Test compilation: cargo check --package leptos-shadcn-command # Run tests: cargo test --package leptos-shadcn-command # Verify functionality: cargo test --package leptos-shadcn-command --lib ``` ## ๐Ÿงช Testing Strategy ### **Compilation Tests** ```bash # Verify no compilation errors: cargo check --package leptos-shadcn-command --lib cargo check --package leptos-shadcn-command --tests ``` ### **Functionality Tests** ```bash # Run all command component tests: cargo test --package leptos-shadcn-command --lib cargo test --package leptos-shadcn-command --test tdd_tests ``` ### **Integration Tests** ```bash # Test command component in example app: cargo run --example leptos-demo ``` ## ๐Ÿ“Š Success Criteria - โœ… **Zero compilation errors** in command component - โœ… **All 68 type mismatch errors resolved** - โœ… **All tests passing** for command component - โœ… **Type-safe prop usage** throughout - โœ… **Consistent API patterns** with other components ## ๐Ÿšจ Risk Mitigation ### **Backup Strategy** ```bash # Create backup branch: git checkout -b fix/command-component-types git add -A && git commit -m "Backup before command component fixes" ``` ### **Incremental Testing** - Fix 10-15 errors at a time - Test compilation after each batch - Commit working fixes immediately ### **Reference Implementation** - Use button component as reference for correct patterns - Compare prop definitions with working components - Maintain consistency with established patterns ## ๐Ÿ“ Related Files - `packages/leptos/command/src/tdd_tests.rs` - Main file with 68 errors - `packages/leptos/command/src/default.rs` - Component implementation - `packages/leptos/command/src/new_york.rs` - Alternative implementation - `packages/leptos/button/src/` - Reference implementation --- **Next Steps**: After fixing command component, proceed to [Tailwind Core Fix](./tailwind-core-fix.md) for remaining compilation issues.