FIX: avoid error when attempting to show ai helper to anon (#549)

Also adds an extra guard around ai helper context positioning.
This commit is contained in:
Sam 2024-03-28 12:24:00 +11:00 committed by GitHub
parent 61e4c56e1a
commit 74c6725c75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -275,6 +275,11 @@ export default class AiHelperContextMenu extends Component {
@afterRender
positionContextMenu() {
this._contextMenu = document.querySelector(".ai-helper-context-menu");
if (!this._dEditorInput || !this._contextMenu) {
return;
}
this.caretCoords = getCaretPosition(this._dEditorInput, {
pos: caretPosition(this._dEditorInput),
});

View File

@ -15,7 +15,7 @@ export function showComposerAIHelper(outletArgs, helper, featureType) {
export function showPostAIHelper(outletArgs, helper) {
return (
_helperEnabled(helper.siteSettings) &&
helper.currentUser.can_use_assistant_in_post
helper.currentUser?.can_use_assistant_in_post
);
}