when local storage is saved it wont display in a HTML text box

I am working on text boxes with an add entry button in HTML. I had got it working through javascript code that when I press the add entry button, I am able to input a text entry then when the page is refreshed the entry remains on the page.

I went on to work on another part of the code and now the data in local storage does not display. I have checked the dev tools and it is definitely being saved but not displayed. My code is below, any help would be greatly appreciated.

function addTextEntry(key, initialText, isNewEntry) {
    var textareaElement = document.createElement("textarea");
    textareaElement.rows = 5;
    textareaElement.placeholder = "(new entry)";

    textareaElement.value = initialText;

    addSection(key, textareaElement);

    if (isNewEntry) {
        textareaElement.focus();
    }

    function saveEntry() {
        console.log("saveEntry called with variables in scope:", {
            key,
            initialText,
            isNewEntry,
            textareaElement,
        });
        
        var text = textareaElement.value;
        var item = makeItem("text", text);
        
    localStorage.setItem(key, item);
        
    }

  textareaElement.addEventListener('change', saveEntry);
    
}

From ‘var text’ downwards is where I have edited the code and this was working before