From 072200b9969d0513cbe697688cc9569b2ff2dacf Mon Sep 17 00:00:00 2001 From: melloware Date: Thu, 6 Jul 2023 10:11:16 -0400 Subject: [PATCH] Fix #4471: Column Resize fix for strict and non-strict mode --- components/lib/carousel/Carousel.js | 2 +- components/lib/datatable/DataTable.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/lib/carousel/Carousel.js b/components/lib/carousel/Carousel.js index 9fe422b319..393eea9dff 100644 --- a/components/lib/carousel/Carousel.js +++ b/components/lib/carousel/Carousel.js @@ -312,7 +312,7 @@ export const Carousel = React.memo( })); useMountEffect(() => { - if (elementRef.current && !attributeSelector.current) { + if (elementRef.current) { attributeSelector.current = UniqueComponentId(); elementRef.current.setAttribute(attributeSelector.current, ''); } diff --git a/components/lib/datatable/DataTable.js b/components/lib/datatable/DataTable.js index 080f816ab6..87582cd9d8 100644 --- a/components/lib/datatable/DataTable.js +++ b/components/lib/datatable/DataTable.js @@ -1,6 +1,5 @@ import * as React from 'react'; -import PrimeReact, { FilterMatchMode, FilterOperator, FilterService } from '../api/Api'; -import { PrimeReactContext } from '../api/Api'; +import PrimeReact, { FilterMatchMode, FilterOperator, FilterService, PrimeReactContext } from '../api/Api'; import { ColumnBase } from '../column/ColumnBase'; import { useEventListener, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks'; import { ArrowDownIcon } from '../icons/arrowdown'; @@ -1340,7 +1339,10 @@ export const DataTable = React.forwardRef((inProps, ref) => { }; useMountEffect(() => { - attributeSelector.current = UniqueComponentId(); + if (elementRef.current) { + attributeSelector.current = UniqueComponentId(); + elementRef.current.setAttribute(attributeSelector.current, ''); + } //setFiltersState(cloneFilters(props.filters)); // Github #4248 setD_filtersState(cloneFilters(props.filters)); @@ -1355,8 +1357,6 @@ export const DataTable = React.forwardRef((inProps, ref) => { }); useUpdateEffect(() => { - elementRef.current.setAttribute(attributeSelector.current, ''); - if (props.responsiveLayout === 'stack' && !props.scrollable) { createResponsiveStyle(); }