@selfcommunity/react-ui 0.7.0-alpha.336 → 0.7.0-alpha.337
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.
|
@@ -59,6 +59,14 @@ export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scrol
|
|
|
59
59
|
*
|
|
60
60
|
*
|
|
61
61
|
* The Composer component contains the logic around the creation of [Post](https://developers.selfcommunity.com/docs/apireference/v2/post/create_a_post) and [Discussion](https://developers.selfcommunity.com/docs/apireference/v2/discussion/create_a_discussion) objects.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
:::info
|
|
65
|
+
To prevent the editor toolbar and action botton bar being hidden underneath the Virtual Keyboard you need to set the `interactive-widget=resizes-content` on meta viewport.
|
|
66
|
+
This works on chrome for android.
|
|
67
|
+
For iOS devices there is a lack of support of this meta so we force the blur event when the user start dragging.
|
|
68
|
+
[More information](https://bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/)
|
|
69
|
+
:::
|
|
62
70
|
|
|
63
71
|
#### Import
|
|
64
72
|
```jsx
|
|
@@ -84,6 +84,14 @@ const reducer = (state, action) => {
|
|
|
84
84
|
*
|
|
85
85
|
*
|
|
86
86
|
* The Composer component contains the logic around the creation of [Post](https://developers.selfcommunity.com/docs/apireference/v2/post/create_a_post) and [Discussion](https://developers.selfcommunity.com/docs/apireference/v2/discussion/create_a_discussion) objects.
|
|
87
|
+
*
|
|
88
|
+
*
|
|
89
|
+
:::info
|
|
90
|
+
To prevent the editor toolbar and action botton bar being hidden underneath the Virtual Keyboard you need to set the `interactive-widget=resizes-content` on meta viewport.
|
|
91
|
+
This works on chrome for android.
|
|
92
|
+
For iOS devices there is a lack of support of this meta so we force the blur event when the user start dragging.
|
|
93
|
+
[More information](https://bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/)
|
|
94
|
+
:::
|
|
87
95
|
|
|
88
96
|
#### Import
|
|
89
97
|
```jsx
|
|
@@ -178,6 +186,7 @@ function Composer(inProps) {
|
|
|
178
186
|
(type === types_1.SCContributionType.POST && ((0, utils_1.stripHtml)(html).length > 0 || medias.length > 0 || hasPoll)) ||
|
|
179
187
|
(type === Composer_1.COMPOSER_TYPE_POLL && hasPoll));
|
|
180
188
|
}, [isLoading, type, title, html, medias, hasPoll]);
|
|
189
|
+
const isIOS = (0, react_1.useMemo)(() => (0, utils_1.iOS)(), []);
|
|
181
190
|
// Load feed object
|
|
182
191
|
(0, react_1.useEffect)(() => {
|
|
183
192
|
if (!editMode) {
|
|
@@ -216,6 +225,16 @@ function Composer(inProps) {
|
|
|
216
225
|
window.onbeforeunload = null;
|
|
217
226
|
}
|
|
218
227
|
}, [state, canSubmit]);
|
|
228
|
+
(0, react_1.useEffect)(() => {
|
|
229
|
+
if (!dialogRef.current || !isIOS) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const handleBlur = () => {
|
|
233
|
+
dialogRef.current.focus();
|
|
234
|
+
};
|
|
235
|
+
dialogRef.current.addEventListener("touchstart", handleBlur);
|
|
236
|
+
return () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("touchstart", handleBlur); };
|
|
237
|
+
}, [dialogRef.current, isIOS]);
|
|
219
238
|
/* Handlers */
|
|
220
239
|
const handleAddLayer = (0, react_1.useCallback)((layer) => setLayer(layer), []);
|
|
221
240
|
const handleRemoveLayer = (0, react_1.useCallback)(() => setLayer(null), []);
|
|
@@ -406,7 +425,6 @@ function Composer(inProps) {
|
|
|
406
425
|
handleClose(event);
|
|
407
426
|
}
|
|
408
427
|
}, [canSubmit, handleAddLayer, handleRemoveLayer, handleClose]);
|
|
409
|
-
const isIOS = (0, react_1.useMemo)(() => (0, utils_1.iOS)(), []);
|
|
410
428
|
// RENDER
|
|
411
429
|
const hasMediaShare = (0, react_1.useMemo)(() => medias.findIndex((m) => m.type === Media_1.MEDIA_TYPE_SHARE) !== -1, [medias]);
|
|
412
430
|
const content = (0, react_1.useMemo)(() => {
|
|
@@ -431,7 +449,7 @@ function Composer(inProps) {
|
|
|
431
449
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
432
450
|
return null;
|
|
433
451
|
}
|
|
434
|
-
return (react_1.default.createElement(Root, Object.assign({ ref: dialogRef, TransitionComponent: DialogTransition, keepMounted: true, onClose: handleClose }, rest, { className: (0, classnames_1.default)(classes.root, { [classes.ios]: isIOS }), scroll: "body", fullScreen: fullScreen }),
|
|
452
|
+
return (react_1.default.createElement(Root, Object.assign({ ref: dialogRef, TransitionComponent: DialogTransition, keepMounted: true, onClose: handleClose }, rest, { className: (0, classnames_1.default)(classes.root, { [classes.ios]: isIOS }), scroll: "body", fullScreen: fullScreen, tabIndex: -1 }),
|
|
435
453
|
react_1.default.createElement("form", { onSubmit: handleSubmit, method: "post" },
|
|
436
454
|
react_1.default.createElement(material_1.DialogTitle, { className: classes.title },
|
|
437
455
|
react_1.default.createElement(material_1.IconButton, { onClick: handleClosePrompt },
|
|
@@ -59,6 +59,14 @@ export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scrol
|
|
|
59
59
|
*
|
|
60
60
|
*
|
|
61
61
|
* The Composer component contains the logic around the creation of [Post](https://developers.selfcommunity.com/docs/apireference/v2/post/create_a_post) and [Discussion](https://developers.selfcommunity.com/docs/apireference/v2/discussion/create_a_discussion) objects.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
:::info
|
|
65
|
+
To prevent the editor toolbar and action botton bar being hidden underneath the Virtual Keyboard you need to set the `interactive-widget=resizes-content` on meta viewport.
|
|
66
|
+
This works on chrome for android.
|
|
67
|
+
For iOS devices there is a lack of support of this meta so we force the blur event when the user start dragging.
|
|
68
|
+
[More information](https://bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/)
|
|
69
|
+
:::
|
|
62
70
|
|
|
63
71
|
#### Import
|
|
64
72
|
```jsx
|
|
@@ -82,6 +82,14 @@ const reducer = (state, action) => {
|
|
|
82
82
|
*
|
|
83
83
|
*
|
|
84
84
|
* The Composer component contains the logic around the creation of [Post](https://developers.selfcommunity.com/docs/apireference/v2/post/create_a_post) and [Discussion](https://developers.selfcommunity.com/docs/apireference/v2/discussion/create_a_discussion) objects.
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
:::info
|
|
88
|
+
To prevent the editor toolbar and action botton bar being hidden underneath the Virtual Keyboard you need to set the `interactive-widget=resizes-content` on meta viewport.
|
|
89
|
+
This works on chrome for android.
|
|
90
|
+
For iOS devices there is a lack of support of this meta so we force the blur event when the user start dragging.
|
|
91
|
+
[More information](https://bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/)
|
|
92
|
+
:::
|
|
85
93
|
|
|
86
94
|
#### Import
|
|
87
95
|
```jsx
|
|
@@ -176,6 +184,7 @@ export default function Composer(inProps) {
|
|
|
176
184
|
(type === SCContributionType.POST && (stripHtml(html).length > 0 || medias.length > 0 || hasPoll)) ||
|
|
177
185
|
(type === COMPOSER_TYPE_POLL && hasPoll));
|
|
178
186
|
}, [isLoading, type, title, html, medias, hasPoll]);
|
|
187
|
+
const isIOS = useMemo(() => iOS(), []);
|
|
179
188
|
// Load feed object
|
|
180
189
|
useEffect(() => {
|
|
181
190
|
if (!editMode) {
|
|
@@ -214,6 +223,16 @@ export default function Composer(inProps) {
|
|
|
214
223
|
window.onbeforeunload = null;
|
|
215
224
|
}
|
|
216
225
|
}, [state, canSubmit]);
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (!dialogRef.current || !isIOS) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const handleBlur = () => {
|
|
231
|
+
dialogRef.current.focus();
|
|
232
|
+
};
|
|
233
|
+
dialogRef.current.addEventListener("touchstart", handleBlur);
|
|
234
|
+
return () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("touchstart", handleBlur); };
|
|
235
|
+
}, [dialogRef.current, isIOS]);
|
|
217
236
|
/* Handlers */
|
|
218
237
|
const handleAddLayer = useCallback((layer) => setLayer(layer), []);
|
|
219
238
|
const handleRemoveLayer = useCallback(() => setLayer(null), []);
|
|
@@ -404,7 +423,6 @@ export default function Composer(inProps) {
|
|
|
404
423
|
handleClose(event);
|
|
405
424
|
}
|
|
406
425
|
}, [canSubmit, handleAddLayer, handleRemoveLayer, handleClose]);
|
|
407
|
-
const isIOS = useMemo(() => iOS(), []);
|
|
408
426
|
// RENDER
|
|
409
427
|
const hasMediaShare = useMemo(() => medias.findIndex((m) => m.type === MEDIA_TYPE_SHARE) !== -1, [medias]);
|
|
410
428
|
const content = useMemo(() => {
|
|
@@ -429,7 +447,7 @@ export default function Composer(inProps) {
|
|
|
429
447
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
430
448
|
return null;
|
|
431
449
|
}
|
|
432
|
-
return (React.createElement(Root, Object.assign({ ref: dialogRef, TransitionComponent: DialogTransition, keepMounted: true, onClose: handleClose }, rest, { className: classNames(classes.root, { [classes.ios]: isIOS }), scroll: "body", fullScreen: fullScreen }),
|
|
450
|
+
return (React.createElement(Root, Object.assign({ ref: dialogRef, TransitionComponent: DialogTransition, keepMounted: true, onClose: handleClose }, rest, { className: classNames(classes.root, { [classes.ios]: isIOS }), scroll: "body", fullScreen: fullScreen, tabIndex: -1 }),
|
|
433
451
|
React.createElement("form", { onSubmit: handleSubmit, method: "post" },
|
|
434
452
|
React.createElement(DialogTitle, { className: classes.title },
|
|
435
453
|
React.createElement(IconButton, { onClick: handleClosePrompt },
|