editor.closeCurrentPopup()
Closes an open editor popup — a dropdown, menu, or dialog panel — and returns focus to the editing area. It is most useful from inside custom toolbar dropdowns, where a button in the panel should dismiss that panel after it does its work.
Syntax
editor.closeCurrentPopup()
Parameters
None in typical use. Called with no arguments it closes the currently open popup. (A specific panel object can be passed to target it, but custom dropdown code normally just calls it with no arguments.)
Returns
Nothing (undefined).
Behavior notes
- Submenu chains are handled.When the open panel belongs to a parent popup, it is unlinked from that parent’s submenu list and its dispose/close handlers run — so closing a nested menu does not leave a dangling reference.
- Focus returns to the editor. After the panel closes, keyboard focus is handed back to the editing area, so the user can keep typing without an extra click.
- It closes the popup, not the editor. Only the transient dropdown/menu/dialog is dismissed; the document and selection are untouched.
Example usage
Inside a custom dropdown, close the panel after the user clicks a button in it:
option.fillpanel = function (panel) {
var btn = document.createElement("button");
btn.textContent = "Insert signature";
btn.onclick = function () {
editor.closeCurrentPopup(); // dismiss the dropdown
editor.insertHTML("<p>-- <br/>Sent from RichTextEditor</p>");
return false;
};
panel.appendChild(btn);
};
var btn = editor.createToolbarDropDown(option, cmd, suffix);Related
- editor.createToolbarDropDown(option, cmd, suffix) — build a custom dropdown whose panel this closes.
- editor.createDialog(...)— build a custom dialog.
- editor.focus()— return focus to the editor explicitly.
Calling editor.closeCurrentPopup() from your app
editor.closeCurrentPopup() belongs to the editor instance. Every integration below works the same way: keep the object that new RichTextEditor(...) returns, and call it on that object.
Plain JavaScript
var editor1 = new RichTextEditor("#div_editor1");
// The constructor is synchronous: the editor is ready on the next line.
editor1.closeCurrentPopup();React and Next.js
// editorRef is filled by the RichTextEditor wrapper from the React guides.
const editorRef = useRef(null);
function onClick() {
editorRef.current?.closeCurrentPopup();
}
return <RichTextEditor editorRef={editorRef} />;In Vue and Angular, the wrapper components in the guides keep the instance in a component variable (editor), so the call is the same. See the React, Vue and Angular pages, or download a tested project from the guides.
If the editor is undefined
- The call ran before the component mounted. Call it from an event handler or after the mount effect has run.
- In React development mode, Strict Mode mounts, unmounts and mounts again, so the wrapper sets
editorRef.currenttonullin between. UseeditorRef.current?.rather than storing the instance elsewhere. - The editor was destroyed (
editor.destroy()) when its component unmounted.
All methods: method reference · all events: event reference.