Skip to content

Commit

Permalink
Merge pull request #2329 from epam/fix-image-upload-width
Browse files Browse the repository at this point in the history
[SlateEditor] fix image width when uploaded
  • Loading branch information
AlekseyManetov authored Jun 6, 2024
2 parents 37e29da + 28efa34 commit 13989f0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions uui-editor/src/plugins/imagePlugin/ImageElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React from 'react';
import {
PlateElement,
PlateElementProps,
Expand Down Expand Up @@ -29,7 +29,6 @@ export const ImageElement = withHOC(ResizableProvider, ({
...props
}: ImageElementProps) => {
const { children, nodeProps } = props;
const imageRef = useRef<HTMLImageElement>();

const focused = useFocused();
const selected = useSelected();
Expand Down Expand Up @@ -72,11 +71,8 @@ export const ImageElement = withHOC(ResizableProvider, ({
)}
<Image
{ ...nodeProps }
ref={ imageRef }
onLoad={ () => {
if (typeof imageRef.current?.width === 'number') {
setWidth(imageRef.current?.width);
}
onLoad={ (event) => {
setWidth((event.target as HTMLImageElement).width);
} }
className={ cx(
css.image,
Expand Down

0 comments on commit 13989f0

Please sign in to comment.