fix: change editor button icon & selection

This commit is contained in:
Aman Harwara
2022-11-23 20:16:43 +05:30
parent c45417623c
commit 9d5a57521e
2 changed files with 8 additions and 2 deletions

View File

@@ -26,7 +26,9 @@ const ChangeEditorButton: FunctionComponent<Props> = ({
const [selectedEditor, setSelectedEditor] = useState(() => {
return note ? application.componentManager.editorForNote(note) : undefined
})
const [selectedEditorIcon, selectedEditorIconTint] = getIconAndTintForNoteType(selectedEditor?.package_info.note_type)
const [selectedEditorIcon, selectedEditorIconTint] = getIconAndTintForNoteType(
note?.noteType || selectedEditor?.package_info.note_type,
)
const [isClickOutsideDisabled, setIsClickOutsideDisabled] = useState(false)
const toggleMenu = useCallback(async () => {

View File

@@ -59,7 +59,11 @@ const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
return item.component?.identifier === currentComponent.identifier
}
return item.noteType === note?.noteType || (!note?.noteType && item.noteType === NoteType.Plain)
const itemNoteTypeIsSameAsCurrentNoteType = item.noteType === note?.noteType
const noteDoesntHaveTypeAndItemIsPlain = !note?.noteType && item.noteType === NoteType.Plain
const unknownNoteTypeAndItemIsPlain = note?.noteType === NoteType.Unknown && item.noteType === NoteType.Plain
return itemNoteTypeIsSameAsCurrentNoteType || noteDoesntHaveTypeAndItemIsPlain || unknownNoteTypeAndItemIsPlain
},
[currentComponent, note],
)