diff --git a/apps/common/mobile/lib/view/collaboration/Comments.jsx b/apps/common/mobile/lib/view/collaboration/Comments.jsx index ff5a69fedc..674eba915b 100644 --- a/apps/common/mobile/lib/view/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/view/collaboration/Comments.jsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect, Fragment} from 'react'; +import React, {useState, useEffect, Fragment, useRef} from 'react'; import {observer, inject} from "mobx-react"; import { f7, Popup, Sheet, Popover, Page, Toolbar, Navbar, NavLeft, NavRight, NavTitle, Link, Input, Icon, List, ListItem, Actions, ActionsGroup, ActionsButton } from 'framework7-react'; import { useTranslation } from 'react-i18next'; @@ -21,12 +21,18 @@ const sliceQuote = (text) => { const AddCommentPopup = inject("storeComments")(observer(props => { const { t } = useTranslation(); const _t = t('Common.Collaboration', {returnObjects: true}); - useEffect(() => { - f7.popup.open('.add-comment-popup'); - if(!Device.android) f7.input.focus('.input-comment'); - }); const userInfo = props.userInfo; const [stateText, setText] = useState(''); + let refInputComment = useRef(null); + + useEffect(() => { + f7.popup.open('.add-comment-popup', false); + + if(refInputComment) { + refInputComment.focus(); + } + }, []); + return ( @@ -60,7 +66,7 @@ const AddCommentPopup = inject("storeComments")(observer(props => {
{userInfo.name}
- {setText(event.target.value);}}> +
@@ -72,6 +78,8 @@ const AddCommentDialog = inject("storeComments")(observer(props => { const _t = t('Common.Collaboration', {returnObjects: true}); const userInfo = props.userInfo; const templateInitials = `
${userInfo.initials}
`; + let refContainerDialog = useRef(null); + useEffect(() => { f7.dialog.create({ destroyOnClose: true, @@ -127,9 +135,15 @@ const AddCommentDialog = inject("storeComments")(observer(props => { } } }).open(); - }); + + if(refContainerDialog) { + const inputComment = refContainerDialog.querySelector('#comment-text'); + inputComment.focus(); + } + }, []); + return ( -
+
refContainerDialog = el} className="add-comment-dialog">
); }));