Jira description field shows value only in Text mode and not in Visual mode

Hi Team,

We are trying to set the value of the description field using JavaScript code:
document.getElementById(“description”).value = response;

where response consist of plain text value. We are able to see the response value in the description field on UI in Issue creation form only in Text mode and not in Visual mode.
Can you please let us know if any specific reason behind this behavior of Jira?

Thanks & Regards,
Preethi H R


If in the browser console, I do this :

var textarea = document.querySelector(‘textarea#description’);

textarea.value += " new formatted text or not";

We can see the result in the description, and it works fine for me.


Hi Fabien,
Thank you for your response.
Yes, you are right. Using the code, I am able to set the value which is visible only in “Text” mode. But if I move to Visual mode, I am not able to see the value that has been set.
Is there any extra code we need to add to make the value visible in “Visual” mode as well.

Thanks & Regards,
Preethi H R

Hi @PreethiHR1

In the first step, you need to select the Text mode. Here’s how you can do it :

var buttons = document.querySelectorAll('button');
var textButton = Array.from(buttons).find(btn => btn.textContent.trim() === 'Text');

After you can do this :

var textarea = document.querySelector('textarea#description');
textarea.value += " new formatted text or not";

And submit form.

I hope this time it will work.

HI Fabien,

Thanks. I tried the above code. But it is setting the contents of my description field only in “Text” mode, if I move back to “Visual” mode then contents are empty.
Attaching the screenshots for reference:

Can you please let me know how I set the same contents using JavaScript in Visual mode of description as well.

Thanks & Regards,
Preethi H R


Can you confirm that when you insert the text, you are in Text mode ?


Yes, I have added below code :
var buttons = document.querySelectorAll(‘button’);
var textButton = Array.from(buttons).find(btn => btn.textContent.trim() === ‘Text’);
var textarea = document.querySelector(‘textarea#description’);
textarea.value = “New text added”;

The new value “New text added” is visible only in “Text” mode and if I shift to “Visual” mode it’s not present.

AJS.$("rich-editor")[0]._setRawContent("*Hello* _world_")

Is probably what you’re looking for. Changing the value of the textarea doesn’t update TinyMCE’s internal state, which indeed gets lost when you switch to visual/text.

That’s strange because it works fine here :slightly_frowning_face: Same result on create/edit issue.
Jira version : 9.12

Screencast from 26-01-2024 09_37_58

May be you can try this with AJS as @PaoloCampanelli suggest :

AJS.$("#description").val("new *formatted* text");

Have a nice day :slight_smile: