Compare commits

...

6 Commits

Author SHA1 Message Date
Germán Jabloñski
4f152488c0 remove useEffect 2025-01-03 15:57:34 -03:00
Germán Jabloñski
c7bf3582a5 Revert "save"
This reverts commit 7ce0ae417f.
2025-01-03 15:52:39 -03:00
Germán Jabloñski
7ce0ae417f save 2025-01-03 15:50:16 -03:00
Germán Jabloñski
1395708fd6 handle no fields scenario 2025-01-03 06:00:05 -03:00
Germán Jabloñski
a2919fcb20 closeDrawer is not needed 2025-01-02 20:31:57 -03:00
Germán Jabloñski
d86c27a331 fix(richtext-lexical): fix inline block drawer opening on mount 2025-01-02 20:19:05 -03:00
2 changed files with 12 additions and 11 deletions

View File

@@ -81,6 +81,7 @@ export const InlineBlockComponent: React.FC<Props> = (props) => {
} = useEditorConfigContext()
const { getFormState } = useServerFunctions()
const editDepth = useEditDepth()
const hasMounted = useRef(false)
const [initialState, setInitialState] = React.useState<false | FormState | undefined>(
initialLexicalFormState?.[formData.id]?.formState,
@@ -116,6 +117,15 @@ export const InlineBlockComponent: React.FC<Props> = (props) => {
const clientBlock = blocksField.blocks[0]
// Open drawer on mount
useEffect(() => {
// > 2 because they always have "id" and "blockName" fields
if (!hasMounted.current && clientBlock.fields.length > 2) {
toggleDrawer()
hasMounted.current = true
}
}, [clientBlock, toggleDrawer])
const removeInlineBlock = useCallback(() => {
editor.update(() => {
$getNodeByKey(nodeKey)?.remove()

View File

@@ -23,7 +23,7 @@ export const ListDrawerContent: React.FC<ListDrawerProps> = ({
onBulkSelect,
onSelect,
overrideEntityVisibility = true,
selectedCollection: selectedCollectionFromProps,
selectedCollection,
}) => {
const { closeModal, isModalOpen } = useModal()
@@ -43,7 +43,7 @@ export const ListDrawerContent: React.FC<ListDrawerProps> = ({
})
const [selectedOption, setSelectedOption] = useState<Option<string>>(() => {
const initialSelection = selectedCollectionFromProps || enabledCollections[0]?.slug
const initialSelection = selectedCollection || enabledCollections[0]?.slug
const found = getEntityConfig({ collectionSlug: initialSelection }) as ClientCollectionConfig
return found
@@ -59,15 +59,6 @@ export const ListDrawerContent: React.FC<ListDrawerProps> = ({
collectionSlug: selectedOption.value,
})
useEffect(() => {
if (selectedCollectionFromProps && selectedCollectionFromProps !== selectedOption?.value) {
setSelectedOption({
label: collections.find(({ slug }) => slug === selectedCollectionFromProps).labels,
value: selectedCollectionFromProps,
})
}
}, [selectedCollectionFromProps, collections, selectedOption])
const renderList = useCallback(
async (slug: string, query?: ListQuery) => {
try {