Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
fix: cant remove flavor (#1011)
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh authored Feb 16, 2024
1 parent 6cdab81 commit 621dd88
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 131 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@graasp/query-client": "2.6.1",
"@graasp/sdk": "3.8.3",
"@graasp/translations": "1.23.0",
"@graasp/ui": "4.8.0",
"@graasp/ui": "4.8.1",
"@mui/icons-material": "5.15.8",
"@mui/lab": "5.0.0-alpha.162",
"@mui/material": "5.15.8",
Expand Down
33 changes: 14 additions & 19 deletions src/components/item/form/DocumentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';

import { TabContext, TabList, TabPanel } from '@mui/lab';
import {
Alert,
Box,
FormControl,
InputLabel,
Expand All @@ -19,6 +18,7 @@ import {
DocumentItemType,
ItemType,
} from '@graasp/sdk';
import { withFlavor } from '@graasp/ui';
import TextEditor from '@graasp/ui/text-editor';

import { useBuilderTranslation } from '../../../config/i18n';
Expand Down Expand Up @@ -68,14 +68,6 @@ export const DocumentExtraForm = ({
],
);

const withFlavor = (textView: JSX.Element): JSX.Element => {
if (!extra.flavor || extra.flavor === DocumentItemExtraFlavor.None) {
return textView;
}

return <Alert severity={extra.flavor}>{textView}</Alert>;
};

const handleChangeEditorMode = (mode: string) => {
// send editor mode change
onEditorChange?.(mode === EditorMode.Raw.toString());
Expand Down Expand Up @@ -125,16 +117,19 @@ export const DocumentExtraForm = ({
</Box>

<TabPanel value={EditorMode.Rich.toString()}>
{withFlavor(
<TextEditor
id={documentItemId}
value={extra.content}
onCancel={onCancel}
onChange={onContentChange}
placeholderText={placeholder}
showActions={false}
/>,
)}
{withFlavor({
content: (
<TextEditor
id={documentItemId}
value={extra.content}
onCancel={onCancel}
onChange={onContentChange}
placeholderText={placeholder}
showActions={false}
/>
),
flavor: extra.flavor,
})}
</TabPanel>
<TabPanel value={EditorMode.Raw.toString()} sx={{ minHeight: '0px' }}>
<TextField
Expand Down
Loading

0 comments on commit 621dd88

Please sign in to comment.