Improve text bug
This commit is contained in:
parent
7da573ffdb
commit
b426c40bd8
3 changed files with 13 additions and 6 deletions
|
@ -85,7 +85,7 @@ export default function ContextMenu({
|
|||
|
||||
const hasGroupSelected = useSelector((s) =>
|
||||
selectedShapeIds.some(
|
||||
(id) => tld.getShape(s.data, id).type === ShapeType.Group
|
||||
(id) => tld.getShape(s.data, id)?.type === ShapeType.Group
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ const ForeignObjectHover = memo(function ForeignObjectHover({
|
|||
}) {
|
||||
const size = useSelector((s) => {
|
||||
const shape = tld.getPage(s.data).shapes[id]
|
||||
if (shape === undefined) return [0, 0]
|
||||
const bounds = getShapeUtils(shape).getBounds(shape)
|
||||
|
||||
return [bounds.width, bounds.height]
|
||||
|
@ -159,8 +160,6 @@ const ForeignObjectRender = memo(function ForeignObjectRender({
|
|||
|
||||
const isEditing = useSelector((s) => s.data.editingId === id)
|
||||
|
||||
const shapeUtils = getShapeUtils(shape)
|
||||
|
||||
useEffect(() => {
|
||||
if (isEditing) {
|
||||
setTimeout(() => {
|
||||
|
@ -171,7 +170,9 @@ const ForeignObjectRender = memo(function ForeignObjectRender({
|
|||
}
|
||||
}, [isEditing])
|
||||
|
||||
return shapeUtils.render(shape, { isEditing, ref: rFocusable })
|
||||
if (shape === undefined) return null
|
||||
|
||||
return getShapeUtils(shape).render(shape, { isEditing, ref: rFocusable })
|
||||
})
|
||||
|
||||
const StyledShape = styled('path', {
|
||||
|
|
|
@ -625,8 +625,14 @@ const state = createState({
|
|||
onExit: ['completeSession', 'clearEditingId'],
|
||||
on: {
|
||||
EDITED_SHAPE: { do: 'updateEditSession' },
|
||||
|
||||
BLURRED_EDITING_SHAPE: { to: 'selecting' },
|
||||
BLURRED_EDITING_SHAPE: [
|
||||
{
|
||||
get: 'editingShape',
|
||||
if: 'shouldDeleteShape',
|
||||
do: ['cancelSession', 'deleteSelection'],
|
||||
},
|
||||
{ to: 'selecting' },
|
||||
],
|
||||
CANCELLED: [
|
||||
{
|
||||
get: 'editingShape',
|
||||
|
|
Loading…
Reference in a new issue