Skip to content
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

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

Open
wants to merge 6 commits into
base: feature/glimmer-paper-grid-tile
Choose a base branch
from

Conversation

matthewhartstonge
Copy link
Contributor

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
Copy link
Contributor Author

matthewhartstonge commented Nov 13, 2024

@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.

Copy link

github-actions bot commented Nov 17, 2024

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

Copy link

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

  • ember-beta

Created by continue-on-error-comment

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.

Convert all components using ember-composability-tools to glimmer
1 participant