@selfcommunity/react-ui 0.10.1-alpha.3 → 0.10.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,9 +69,6 @@ function CommentObjectReply(inProps) {
69
69
  const scUserContext = (0, react_core_1.useSCUser)();
70
70
  // RETRIEVE OBJECTS
71
71
  const [html, setHtml] = (0, react_1.useState)(text);
72
- // HOOKS
73
- const theme = (0, material_1.useTheme)();
74
- const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
75
72
  // REFS
76
73
  let editor = (0, react_1.useRef)();
77
74
  /**
@@ -85,10 +82,15 @@ function CommentObjectReply(inProps) {
85
82
  * Focus on editor
86
83
  */
87
84
  const handleEditorFocus = () => {
88
- if (!isMobile && editor.current) {
85
+ if (editor.current) {
89
86
  editor.current.focus();
90
87
  }
91
88
  };
89
+ (0, react_1.useEffect)(() => {
90
+ const focusOnUserInteraction = () => handleEditorFocus();
91
+ document.addEventListener('touchstart', focusOnUserInteraction);
92
+ return () => document.removeEventListener('touchstart', focusOnUserInteraction);
93
+ }, []);
92
94
  /**
93
95
  * Handle Replay
94
96
  */
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import Widget from '../Widget';
6
6
  import { FormattedMessage } from 'react-intl';
7
- import { Avatar, Stack, useMediaQuery, useTheme } from '@mui/material';
7
+ import { Avatar, Stack } from '@mui/material';
8
8
  import { useSCUser } from '@selfcommunity/react-core';
9
9
  import Editor from '../Editor';
10
10
  import classNames from 'classnames';
@@ -67,9 +67,6 @@ export default function CommentObjectReply(inProps) {
67
67
  const scUserContext = useSCUser();
68
68
  // RETRIEVE OBJECTS
69
69
  const [html, setHtml] = useState(text);
70
- // HOOKS
71
- const theme = useTheme();
72
- const isMobile = useMediaQuery(theme.breakpoints.down('md'));
73
70
  // REFS
74
71
  let editor = useRef();
75
72
  /**
@@ -83,10 +80,15 @@ export default function CommentObjectReply(inProps) {
83
80
  * Focus on editor
84
81
  */
85
82
  const handleEditorFocus = () => {
86
- if (!isMobile && editor.current) {
83
+ if (editor.current) {
87
84
  editor.current.focus();
88
85
  }
89
86
  };
87
+ useEffect(() => {
88
+ const focusOnUserInteraction = () => handleEditorFocus();
89
+ document.addEventListener('touchstart', focusOnUserInteraction);
90
+ return () => document.removeEventListener('touchstart', focusOnUserInteraction);
91
+ }, []);
90
92
  /**
91
93
  * Handle Replay
92
94
  */