How to close the modal dialog of a UI Kit 2 Confluence ContentAction?

The reason that the form disappears is that you are returning null when isOpen is false, which renders nothing.


I’m also interested in whether it’s possible to close a UI Kit 2 view programatically. As mentioned above, calling view.close doesn’t work. For example, I created this confluence:contentAction using UI Kit 2:

import React from "react";
import ForgeReconciler, { Form, TextField } from "@forge/react";
import { view } from "@forge/bridge";

const App = () => {
  return (
    <Form
      onSubmit={() => {
        view.close().catch((e) => {
          console.log("error closing", e);
        });
      }}
    >
      <TextField name="username" label="Username" />
    </Form>
  );
};

ForgeReconciler.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

which looks like this:

when submitting the form, the following is logged:

[Log] error closing – Error: this resource's view is not closable. (main.js, line 2)

I’ve also tested a bitbucket:repoCodeOverviewAction which rejects the close promise with the same error.

cc @ddraper @QuocLieu can see that you’ve worked on UI Kit 2 so wondering whether you may know?

1 Like