Cant make executeAsModal work

Hi,
I am trying to use await core.executeAsModal(makeDefaultDocument); but for some reason it doesn`t work. I tried everything i can think of. It just does nothing: no debugger errors or exceptions.

I use manifest v.5, project is React one. What could be the reason?


async function makeDefaultDocument(executionContext) {
    let myDoc = await app.createDocument({ preset: "My Web Preset 1" });
}

export const SectionEl = () => {
    const isMounted = useRef(true);
    const [done, setDone] = useState(false)

    const handleOnClick = async (e) => {
        e.preventDefault();

        console.log("handleOnClick");
        try {
            //This also doesnt work
            // let newDocument = await app.documents.add({
            //     width: 800,
            //     height: 600,
            //     resolution: 300,
            //     mode: "RGBColorMode",
            //     fill: "transparent"
            // });

            await core.executeAsModal(makeDefaultDocument);
        } catch (error) {
            showAlert(error);
        }
    }

    useEffect(() => {
        return () => {
            isMounted.current = false;
        };
    }, []);

    return (
        <div>          
            <sp-button onClick={handleOnClick} >Remove</sp-button>
        </div>
    )

Does it even get to makeDefaultDocument? Could you try debugging where it stops?

Yep, it hits it I can step through them.

So it looks like your app.createDocument({ preset: "My Web Preset 1" }) doesn’t work and not modal execution :thinking: Do you have such preset (I believe it might case sensitive)?

What do you get if try like this?

app.createDocument({ preset: "My Web Preset 1" }).then(
  (success) => console.log(success),
  (fail) => console.log(fail)
)

I was able to make it work like this:

const makeDoc = async ()=>{
let newDocument = await app.documents.add({
width: 800,
height: 600,
resolution: 300,
mode: “RGBColorMode”,
fill: “transparent”
});
};

Maybe something with app.createDocument should be set differently.

Thank you!