@gravity-ui/page-constructor 4.38.0 → 4.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,20 +28,26 @@ const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered
28
28
  const mediaWidth = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
29
29
  const captionId = (0, uikit_1.useUniqId)();
30
30
  const themedMedia = (0, utils_2.getThemedValue)(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media, theme);
31
- const hasNoImage = !(themedMedia === null || themedMedia === void 0 ? void 0 : themedMedia.image) || !(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image);
31
+ const hasNoImage = !(themedMedia === null || themedMedia === void 0 ? void 0 : themedMedia.image) && !(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image);
32
32
  const mediaVideoHeight = hasNoImage && mediaWidth && (0, VideoBlock_1.getHeight)(mediaWidth);
33
33
  const [minImageHeight, setMinImageHeight] = (0, react_1.useState)((_b = ref === null || ref === void 0 ? void 0 : ref.current) === null || _b === void 0 ? void 0 : _b.offsetHeight);
34
34
  // TODO remove property support activeTabData?.image. Use only activeTabData?.media?.image
35
35
  let imageProps;
36
36
  const handleImageHeight = (0, react_1.useCallback)(() => {
37
- var _a;
38
- setMinImageHeight((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetHeight);
39
- }, []);
40
- const onSelectTab = (id, e) => {
37
+ var _a, _b;
38
+ if (minImageHeight !== ((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetHeight)) {
39
+ setMinImageHeight((_b = ref === null || ref === void 0 ? void 0 : ref.current) === null || _b === void 0 ? void 0 : _b.offsetHeight);
40
+ }
41
+ }, [minImageHeight]);
42
+ const onSelectTab = (0, react_1.useCallback)((id, e) => {
41
43
  setActiveTab(id);
42
44
  handleImageHeight();
43
- e.currentTarget.scrollIntoView({ inline: 'center', behavior: 'smooth', block: 'nearest' });
44
- };
45
+ e.currentTarget.scrollIntoView({
46
+ inline: 'center',
47
+ behavior: 'smooth',
48
+ block: 'nearest',
49
+ });
50
+ }, [handleImageHeight]);
45
51
  if (activeTabData) {
46
52
  const themedImage = (0, utils_2.getThemedValue)(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image, theme);
47
53
  imageProps = themedImage && (0, utils_1.getMediaImage)(themedImage);
@@ -25,20 +25,26 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
25
25
  const mediaWidth = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
26
26
  const captionId = useUniqId();
27
27
  const themedMedia = getThemedValue(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media, theme);
28
- const hasNoImage = !(themedMedia === null || themedMedia === void 0 ? void 0 : themedMedia.image) || !(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image);
28
+ const hasNoImage = !(themedMedia === null || themedMedia === void 0 ? void 0 : themedMedia.image) && !(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image);
29
29
  const mediaVideoHeight = hasNoImage && mediaWidth && getHeight(mediaWidth);
30
30
  const [minImageHeight, setMinImageHeight] = useState((_b = ref === null || ref === void 0 ? void 0 : ref.current) === null || _b === void 0 ? void 0 : _b.offsetHeight);
31
31
  // TODO remove property support activeTabData?.image. Use only activeTabData?.media?.image
32
32
  let imageProps;
33
33
  const handleImageHeight = useCallback(() => {
34
- var _a;
35
- setMinImageHeight((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetHeight);
36
- }, []);
37
- const onSelectTab = (id, e) => {
34
+ var _a, _b;
35
+ if (minImageHeight !== ((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetHeight)) {
36
+ setMinImageHeight((_b = ref === null || ref === void 0 ? void 0 : ref.current) === null || _b === void 0 ? void 0 : _b.offsetHeight);
37
+ }
38
+ }, [minImageHeight]);
39
+ const onSelectTab = useCallback((id, e) => {
38
40
  setActiveTab(id);
39
41
  handleImageHeight();
40
- e.currentTarget.scrollIntoView({ inline: 'center', behavior: 'smooth', block: 'nearest' });
41
- };
42
+ e.currentTarget.scrollIntoView({
43
+ inline: 'center',
44
+ behavior: 'smooth',
45
+ block: 'nearest',
46
+ });
47
+ }, [handleImageHeight]);
42
48
  if (activeTabData) {
43
49
  const themedImage = getThemedValue(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image, theme);
44
50
  imageProps = themedImage && getMediaImage(themedImage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "4.38.0",
3
+ "version": "4.38.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {