Skip to content

Commit b7c6d1c

Browse files
kkmchKezhik Kyzyl-ool
kkmch
authored and
Kezhik Kyzyl-ool
committed
feat: using extraProps in Image
1 parent fc9f16f commit b7c6d1c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/blocks/Tabs/Tabs.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const TabsBlock = ({
7373

7474
if (activeTabData.caption && imageProps) {
7575
Object.assign(imageProps, {
76-
'aria-describedby': captionId,
76+
extraProps: {
77+
'aria-describedby': captionId,
78+
},
7779
});
7880
}
7981
}

src/components/Image/Image.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {
22
CSSProperties,
33
Fragment,
4+
HTMLProps,
45
MouseEventHandler,
56
ReactEventHandler,
67
useContext,
@@ -12,14 +13,15 @@ import {ProjectSettingsContext} from '../../context/projectSettingsContext';
1213
import {ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';
1314
import {getQaAttrubutes} from '../../utils';
1415
import {isCompressible} from '../../utils/imageCompress';
15-
import ImageBase from '../ImageBase/ImageBase';
16+
import ImageBase, {ImageBaseProps} from '../ImageBase/ImageBase';
1617

1718
export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {
1819
style?: CSSProperties;
1920
className?: string;
2021
onClick?: MouseEventHandler;
2122
onLoad?: ReactEventHandler<HTMLDivElement>;
2223
containerClassName?: string;
24+
extraProps?: Omit<HTMLProps<HTMLImageElement>, keyof ImageBaseProps>;
2325
}
2426

2527
export interface DeviceSpecificFragmentProps extends QAProps {
@@ -66,6 +68,7 @@ const Image = (props: ImageProps) => {
6668
onLoad,
6769
containerClassName,
6870
qa,
71+
extraProps,
6972
} = props;
7073
const [imgLoadingError, setImgLoadingError] = useState(false);
7174

@@ -123,6 +126,7 @@ const Image = (props: ImageProps) => {
123126
onClick={onClick}
124127
onError={() => setImgLoadingError(true)}
125128
onLoad={onLoad}
129+
{...extraProps}
126130
/>
127131
</picture>
128132
);

src/models/constructor-items/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ interface LoopProps {
124124

125125
// images
126126

127-
export interface ImageInfoProps extends Pick<HTMLProps<HTMLImageElement>, 'aria-describedby'> {
127+
export interface ImageInfoProps {
128128
alt?: string;
129129
disableCompress?: boolean;
130130
}

0 commit comments

Comments
 (0)