Skip to content

Commit

Permalink
Add textarea array rendering support in SmartViewAdapter
Browse files Browse the repository at this point in the history
- Introduced a new rendering method for textarea arrays in the SmartViewAdapter, enhancing the component's capabilities.
- Updated the existing textarea rendering method to include debouncing for change events, improving performance and user experience.
- This change aims to provide better handling of textarea inputs, particularly when dealing with arrays, and ensures a more responsive interface.
  • Loading branch information
Brian Joseph Petro committed Dec 25, 2024
1 parent c5f6644 commit 7d922cd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions smart-view/adapters/_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class SmartViewAdapter {
dropdown: this.render_dropdown_component,
toggle: this.render_toggle_component,
textarea: this.render_textarea_component,
textarea_array: this.render_textarea_array_component,
button: this.render_button_component,
remove: this.render_remove_component,
folder: this.render_folder_select_component,
Expand Down Expand Up @@ -232,6 +233,19 @@ export class SmartViewAdapter {
}

render_textarea_component(elm, path, value, scope) {
const smart_setting = new this.setting_class(elm);
smart_setting.addTextArea(textarea => {
textarea.setPlaceholder(elm.dataset.placeholder || "");
textarea.setValue(value || "");
let debounceTimer;
textarea.onChange(async (value) => {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => this.handle_on_change(path, value, elm, scope), 2000);
});
});
return smart_setting;
}
render_textarea_array_component(elm, path, value, scope) {
const smart_setting = new this.setting_class(elm);
smart_setting.addTextArea(textarea => {
textarea.setPlaceholder(elm.dataset.placeholder || "");
Expand Down

0 comments on commit 7d922cd

Please sign in to comment.