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

BUG: Trait's setValue() method not called when value changes #6180

Closed
2 tasks done
padcom opened this issue Sep 30, 2024 · 8 comments · Fixed by #6204
Closed
2 tasks done

BUG: Trait's setValue() method not called when value changes #6180

padcom opened this issue Sep 30, 2024 · 8 comments · Fixed by #6204

Comments

@padcom
Copy link
Contributor

padcom commented Sep 30, 2024

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Chrome latest

Reproducible demo link

https://codesandbox.io/p/sandbox/withered-rgb-xmw8gk

Describe the bug

How to reproduce the bug?

  1. Open code sandbox
  2. Select "body" (type: 'wrapper') - observe alert about getting value from custom source (trait.getValue() is called)
  3. Try to change the value (trait: custom, the only one there) - observe the "setValue()" is not called as no alert is shown

What is the expected behavior?
An alert "Setting global value to " + value is shown

What is the current behavior?
Alert not shown, the trait.setValue() method is not called.

If is necessary to execute some code in order to reproduce the bug, paste it here below:

// your code here

Code of Conduct

  • I agree to follow this project's Code of Conduct
@padcom
Copy link
Contributor Author

padcom commented Sep 30, 2024

From what I can see the Trait.setValue() is not called when the value comes from an input. Instead the setTargetValue() is called which doesn't check if the setValue() method of the trait definition is there. Also, the Trait.setValue() checks for the setValue key in attributes whereas Trait.getValue() gets its custom getter via this.get('getValue') (Trait.ts:303)

@padcom
Copy link
Contributor Author

padcom commented Sep 30, 2024

I tried following this discussion to get it working but as you can see in the sandbox it just doesn't work.

@mohamedsalem401
Copy link
Member

Hey @padcom ,

I think the value is updating (because the HTML DOM attributes are updated), however, it seems like there might be an issue with the value in the input not being updated. Also, it's not just related to the wrapper component but rather all types being added.

I'll look into it and let you know if it's a bug or something is wrong with the code snippit

@padcom
Copy link
Contributor Author

padcom commented Oct 1, 2024

Also, it's not just related to the wrapper component but rather all types being added.

That is correct. It's for all component types and for all trait types.

@padcom
Copy link
Contributor Author

padcom commented Oct 9, 2024

That's great news! Thank you!!!

@padcom
Copy link
Contributor Author

padcom commented Oct 18, 2024

@artf Do you have a release date in mind when this fix could be available?

@artf
Copy link
Member

artf commented Oct 21, 2024

@padcom
Copy link
Contributor Author

padcom commented Oct 21, 2024

Thank you! I verified and it is working as expected!

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 a pull request may close this issue.

3 participants