ember-paper icon indicating copy to clipboard operation
ember-paper copied to clipboard

feat(addon/components/paper-form): converts to a glimmer component.

Open matthewhartstonge opened this issue 1 year ago • 2 comments

Converts paper-form to a glimmer component.

Breaking Change

The ChildMixin makes a call to a deprecated internal/private Ember.ViewMixin.nearestOfType function to find the parent component (based on the ParentMixin) so that it can magically register the non-contextual component as a child.

As such, the following test now fails, and I have marked as skip:

Integration | Component | paper form: works without using contextual components

To ease migration, we can yield the parent into the hash, in which case it would be up to users to inject the parent into any non-contexual components that accept a parent component as an argument (PaperItem, PaperInput, e.t.c).

I have created a new test which is a copy of the old, but passes in the yielded parent, which uses this pattern and passes:

Integration | Component | paper form: works without using contextual components by binding in the yielded parent

The troublesome mixin code:

// addon/mixins/child-mixin.js

export default Mixin.create({
  // override to look for a specific parent class
  parentClass: ParentMixin,

  // this will typically be overriden when yielding a contextual component
  parentComponent: computed({
    get() {
      if (this._parentComponent !== undefined) {
        return this._parentComponent;
      }

      return this.nearestOfType(this.parentClass);
    },

    set(key, value) {
      return this._parentComponent = value;
    }
  }),

Refer: https://api.emberjs.com/ember/5.12/classes/Ember.ViewMixin/methods/nearestOfType?anchor=nearestOfType&show=inherited,protected,private,deprecated

matthewhartstonge avatar Nov 13 '24 00:11 matthewhartstonge

@mansona have you come across this this type of error before?

Seems to only rear its head on 3.24... 3.20 passes 3.28 passes

I think this could be related to the ValidationMixin so I'm hoping it may come out in the wash as I glimmer~ise the components?

not ok 76 Chrome 130.0 - [35 ms] - Integration | Component | paper form: form `onSubmit` action is invoked when form element is submitted
    ---
        stack: >
            Error: Assertion Failed: You attempted to update `[]` on `<Array:ember710>`, but it had already been used previously in the same computation.  Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.
            
            `[]` was first used:
            
            - While rendering:
              -top-level
                application
                  index
                    paper-form
                      (result of a `unknown` helper)
                        (result of a `hash` helper).input
                          (result of a `hash` helper)
                            @isValid
                              this.isValid
            
            Stack trace for the update:
                at dirtyTagFor (http://localhost:7357/assets/vendor.js:65788:37)
                at markObjectAsDirty (http://localhost:7357/assets/vendor.js:23931:32)
                at notifyPropertyChange (http://localhost:7357/assets/vendor.js:23969:5)
                at arrayContentDidChange (http://localhost:7357/assets/vendor.js:24079:7)
                at replaceInNativeArray (http://localhost:7357/assets/vendor.js:24144:5)
                at replace (http://localhost:7357/assets/vendor.js:24121:7)
                at insertAt (http://localhost:7357/assets/vendor.js:36010:24)
        message: >
            global failure: Error: Assertion Failed: You attempted to update `[]` on `<Array:ember710>`, but it had already been used previously in the same computation.  Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

matthewhartstonge avatar Nov 13 '24 14:11 matthewhartstonge

Some tests with 'continue-on-error: true' have failed:

github-actions[bot] avatar Dec 30 '24 11:12 github-actions[bot]