Should Code Run When Modal Dialog Is Open?

Hard to explain what I am seeing but will try to explain…

API2
Manifest 5

I have a button which opens a Modal Dialog using sp-dialog

Should code run whilst the Dialog is open ?

    document.querySelector("#modal-customSize").setAttribute("open");
    console.log("HERE"); <=== this executes when the modal is open

Why shouldn’t it? What first line does, is make html element (in this case your dialog) visible and nothing is stopping the script from running the next line of code

Figured it out now thanks