Text disappears after changing focus when typing into walmart.com search bar using JavaScript and Python

I am building a web-scrapper to monitor prices for a few things that go on sale every now and then.

So far I have the following function. I found the search bar element and can send text into it. However the text does not “stick”. Whenever I click on the background of the site, or even the textbox itself and change focus, the text disappears.

Why is this? I can physically see the text in the search bar being input, but it just disappears and cannot be entered in. What am I doing wrong?

def type_in_searchbar(websocket_url, search_term):
    # Type the search term into the Walmart search bar
    try:
        ws = create_connection(websocket_url)

        script = f"""
        var searchBar = document.querySelector('input[aria-label="Search"]');
        if (searchBar) {{
            searchBar.focus();
            searchBar.value = '{search_term}';
        }}
        """

        command = {
            "id": 1,
            "method": "Runtime.evaluate",
            "params": {
                "expression": script
            }
        }

        ws.send(json.dumps(command))
        ws.close()
        print(f"Typed '{search_term}' into the search bar!")
    except Exception as e:
        print(f"Error typing in the search bar: {e}")