-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix: textarea value not saved/rendered #390
Conversation
// actions here will be applied to the preview in the editor | ||
action: { | ||
input: function ({ target: { value } }) { | ||
this.setData?.('value', value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
will be the Field instance when called from editor preview
@@ -379,7 +375,14 @@ export class Controls { | |||
this.container = container | |||
this.groupOrder = unique(groupOrder.concat(['common', 'html', 'layout'])) | |||
this.options = options | |||
return Promise.all(this.registerControls([...defaultElements, ...elements])) | |||
|
|||
const layoutControls = await import('./layout/index.js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using dynamic import to prevent circular dependency found when writing tests for controls
@@ -130,13 +130,15 @@ export default class Field extends Component { | |||
} | |||
} | |||
|
|||
setData = (path, value) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shortcut for setting data without updating the preview or edit panels
@@ -310,7 +312,10 @@ export default class Field extends Component { | |||
const prevData = clone(this.data) | |||
const { action = {} } = controls.get(prevData.config.controlId) | |||
prevData.id = `prev-${this.id}` | |||
prevData.action = action | |||
prevData.action = Object.entries(action).reduce((acc, [key, value]) => { | |||
acc[key] = value.bind(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this one but it binds the Field instance so we have access to setData
from the component class.
🎉 This PR is included in version 3.1.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
You changed the logic and the meaning of the textarea as the rest of the inputs are created The value was already being stored like the other inputs, the problem was that when the form was rendered it didn't grab the value of the attrs Now all the logic changes, and you have to add a lot more code to just condition the textarea, the idea was that just as it renders the input text, email, etc it would also grab the value from the attrs array, and not leave it aside. In other words, it was going to take the value of attrs and not create another value outside of attrs |
i see what you mean. will take another look |
essentially, the HTMLTextAreaElement has a setter that allows |
i removed the custom input handler on the textarea class in favor of the built-in preview handler on the Field class. this still uses a root level assignment of content instead of value as |
resolves #388