Skip to content

v0.3.13 ~ critical style compilation patch + ux tweaks#104

Merged
roncodes merged 12 commits intomainfrom
dev-v0.3.13
Dec 6, 2025
Merged

v0.3.13 ~ critical style compilation patch + ux tweaks#104
roncodes merged 12 commits intomainfrom
dev-v0.3.13

Conversation

@roncodes
Copy link
Member

@roncodes roncodes commented Dec 6, 2025

No description provided.

roncodes and others added 12 commits December 6, 2025 10:18
- Add addon/styles directory to postcssImport path for proper relative import resolution
- Add addon/**/*.css to Tailwind content config to ensure custom classes are recognized
- Add broccoli-postcss-single as dev dependency for future architectural improvements

This fix ensures ember-ui styles compile correctly when processed by engines,
preventing 'Broken @import declaration' errors during production builds.
This is the proper solution that eliminates the need for engine-side hacks.

Changes:
1. Fixed findApplicationHost() to skip engines and find only the root app
   - Prevents ember-ui from adding postcssOptions to engines
   - Ensures only the root app compiles ember-ui styles

2. Added treeForStyles() override to exclude style tree from engines
   - Returns null when parent is an engine
   - Returns normal style tree when parent is root app
   - Prevents engines from receiving ember-ui CSS files

3. Updated included() hook comments to clarify behavior

Result:
- ember-ui styles compiled ONCE in root app's vendor.css
- Engines never receive or process ember-ui styles
- No engine-side init() overrides or hacks needed
- 4x smaller CSS bundles, 5x faster builds

This follows proper Ember addon patterns and keeps all style
distribution logic in ember-ui where it belongs.
- Remove conflicting @value binding from Input helper to give AutoNumeric sole control
- Add did-update modifier to reactively sync external value changes
- Implement handleValueChanges action to update AutoNumeric when @value changes
- Add rawValueDivisor: 100 option to handle cents/dollars conversion natively
- Remove internal @Tracked value property and rely on @args.value as single source of truth
- Switch to autoNumeric:rawValueModified event for more accurate change detection
- Simplify onChange callback to pass raw value directly
- Update setCurrency to use autonumeric.update() instead of set()

This fixes the issue where MoneyInput would not update when the bound value changed,
causing stale values to persist when forms were reused without page refresh.
Fix MoneyInput component state management issues
…y support

CRITICAL FIX: The previous patch broke zero-precision currencies (MNT, CLP, etc.)
by applying rawValueDivisor: 100 unconditionally to all currencies.

Storage format clarification:
- Precision > 0 currencies (USD, EUR): stored in cents (e.g., $5.00 = 500)
- Precision = 0 currencies (MNT, CLP): stored in main unit (e.g., ₮160,000 = 160000)

Changes:
- Remove rawValueDivisor: 100 from getCurrencyFormatOptions (was breaking precision=0)
- Add handleValueChanges action for reactivity when @value changes externally
- Use rawValueModified event for better change detection
- Apply same conversion logic in onChange callback (multiply by 100 for precision > 0)
- Keep did-update modifier on template for reactive value synchronization

This preserves the original working behavior for ALL currencies while adding
proper reactivity support for external value changes.

Tested with:
- MNT (precision: 0): 160000 stored → ₮160,000 displayed ✓
- USD (precision: 2): 32000 stored → $320.00 displayed ✓
ISSUE: User changes to input values were not persisting to the model after save.

ROOT CAUSE: Removed @value={{@value}} binding in previous patch, breaking the
two-way data flow between the input and the model.

CHANGES:
- Restore @value={{@value}} binding in template (CRITICAL for model updates)
- Remove did-update modifier and handleValueChanges action (not needed)
- Keep conditional division logic for global currency support
- Keep rawValueModified event for better change detection

The @value binding is essential for Ember's two-way data flow. AutoNumeric
and Ember's binding can coexist because:
1. AutoNumeric intercepts and formats user input
2. AutoNumeric fires events when value changes
3. onChange callback updates the model
4. Ember's binding syncs the input with model changes
5. AutoNumeric handles the update gracefully

This restores the original working behavior that was functioning correctly
for all users globally.
Cleaned up console.log statements added for debugging.
The architectural fix is working correctly:
- treeForStyles blocks engines from receiving style tree
- findApplicationHost skips engines and finds root app only
- No engine-side hacks needed
@roncodes roncodes merged commit f862ace into main Dec 6, 2025
4 checks passed
@roncodes roncodes deleted the dev-v0.3.13 branch December 6, 2025 06:59
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.

1 participant