Question
Enigma Metaverse
IN
Last activity: 10 May 2025 22:34 EDT
On load of the section how to set focus on the rich text editor field of the form rather than the first action field ?
I want (mouse cursor) to set the focus on the body of the email which is the correspondence rule rather than pointing on the first field of the section.
I am able to change the focus from first field to the another filed using the below script in the UserWorkFrom.
<script>
setTimeout(function(){
document.querySelectorAll('[data-test-id="MY"]')[0].focus();
}, 1000);
</script>
but how to set focus on the Richtexteditor.
I tried the above script but no luck.
------------------------------------------
another approach which I've been following is
I've created a when rule which checks the length of "pyToRecipient" (page list property), if this page list has at least one record then result is true, so using this when rule i'm calling the "non-auto generated" html section inside the correspondence rule by applying this when condition as visibility .
I've added this container inside the source of the correspondence
<div id="messageInput" contenteditable="true"
</div>
I want (mouse cursor) to set the focus on the body of the email which is the correspondence rule rather than pointing on the first field of the section.
I am able to change the focus from first field to the another filed using the below script in the UserWorkFrom.
<script>
setTimeout(function(){
document.querySelectorAll('[data-test-id="MY"]')[0].focus();
}, 1000);
</script>
but how to set focus on the Richtexteditor.
I tried the above script but no luck.
------------------------------------------
another approach which I've been following is
I've created a when rule which checks the length of "pyToRecipient" (page list property), if this page list has at least one record then result is true, so using this when rule i'm calling the "non-auto generated" html section inside the correspondence rule by applying this when condition as visibility .
I've added this container inside the source of the correspondence
<div id="messageInput" contenteditable="true"
</div>
could anyone please help.
Thanks in advance
Regards,
Manoj
***Edited by Moderator Marije to change type from General to Product, added Product details and Capability tags****
@Manoj Kumar Akkala
To set focus on the rich text editor field on load instead of the first action field, you can use JavaScript to target the specific element. The approach you tried with the
setTimeoutfunction can be modified to focus on the rich text editor field. You can add the following script to your section:<script> setTimeout(function(){ document.querySelector('[data-test-id="richTextEditor"]')?.focus(); }, 1000); </script>This script will wait for 1 second after the section loads and then focus on the element with the data-test-id
richTextEditor. Make sure thedata-test-idmatches the identifier for your rich text editor. If you're using a custom HTML element inside the correspondence rule, ensure theidor other selector matches correctly. Additionally, the approach of using the "when" rule to control visibility works fine, but the focus needs to be applied after the element is visible.