Skip to content

Commit

Permalink
Fix tests and prevent class="" in DOM (#4805)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Aug 21, 2023
1 parent 3a00801 commit a5f2cda
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
10 changes: 6 additions & 4 deletions components/lib/carousel/Carousel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext, ariaLabel } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMountEffect, usePrevious, useResizeListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { useMountEffect, usePrevious, useResizeListener, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { ChevronLeftIcon } from '../icons/chevronleft';
import { ChevronRightIcon } from '../icons/chevronright';
Expand Down Expand Up @@ -326,9 +326,11 @@ export const Carousel = React.memo(
elementRef.current.setAttribute(attributeSelector.current, '');
}

calculatePosition();
changePosition(totalShiftedItemsState);
bindWindowResizeListener();
if (!carouselStyle.current) {
calculatePosition();
changePosition(totalShiftedItemsState);
bindWindowResizeListener();
}
});

useUpdateEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion components/lib/componentbase/ComponentBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ export const ComponentBase = {
...ObjectUtils.getMergedProps(self, globalPT)
};

const mergedClassName = [globalPT.className, self.className].filter(Boolean).join(' ').trim();
let mergedClassName = [globalPT.className, self.className].filter(Boolean).join(' ').trim();

mergedClassName = ObjectUtils.isEmpty(mergedClassName) ? undefined : mergedClassName;

if (Object.keys(datasetProps).length) {
merged = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`ProgressBar default 1`] = `
<div
class="p-progressbar-value p-progressbar-value-animate"
data-pc-section="value"
style="width: 2%; display: flex; background-color: transparent;"
style="display: flex;"
/>
</div>
</div>
Expand Down Expand Up @@ -77,7 +77,7 @@ exports[`ProgressBar mode indeterminate 1`] = `
>
<div
class="p-progressbar-indeterminate-container"
data-pc-section="indeterminatecontainer"
data-pc-section="container"
>
<div
class="p-progressbar-value p-progressbar-value-animate"
Expand Down
18 changes: 9 additions & 9 deletions components/lib/skeleton/__snapshots__/Skeleton.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`Skeleton animation none 1`] = `
class="p-skeleton p-component p-skeleton-none"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem;"
style="width: 100%; height: 1rem; position: relative;"
/>
</div>
`;
Expand All @@ -17,7 +17,7 @@ exports[`Skeleton animation wave 1`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem;"
style="width: 100%; height: 1rem; position: relative;"
/>
</div>
`;
Expand All @@ -28,7 +28,7 @@ exports[`Skeleton border radius 1`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem; border-radius: 16px;"
style="width: 100%; height: 1rem; border-radius: 16px; position: relative;"
/>
</div>
`;
Expand All @@ -39,7 +39,7 @@ exports[`Skeleton border radius 2`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem; border-radius: 16px;"
style="width: 100%; height: 1rem; border-radius: 16px; position: relative;"
/>
</div>
`;
Expand All @@ -50,7 +50,7 @@ exports[`Skeleton default 1`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem;"
style="width: 100%; height: 1rem; position: relative;"
/>
</div>
`;
Expand All @@ -61,7 +61,7 @@ exports[`Skeleton shape circle 1`] = `
class="p-skeleton p-component p-skeleton-circle"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem;"
style="width: 100%; height: 1rem; position: relative;"
/>
</div>
`;
Expand All @@ -72,7 +72,7 @@ exports[`Skeleton shape rectangle 1`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 1rem;"
style="width: 100%; height: 1rem; position: relative;"
/>
</div>
`;
Expand All @@ -83,7 +83,7 @@ exports[`Skeleton size in pixels 1`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 50px; height: 50px;"
style="width: 50px; height: 50px; position: relative;"
/>
</div>
`;
Expand All @@ -94,7 +94,7 @@ exports[`Skeleton size width and height 1`] = `
class="p-skeleton p-component"
data-pc-name="skeleton"
data-pc-section="root"
style="width: 100%; height: 2rem;"
style="width: 100%; height: 2rem; position: relative;"
/>
</div>
`;
5 changes: 4 additions & 1 deletion components/lib/utils/MergeProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export function mergeProps(...props) {
if (key === 'style') {
merged['style'] = { ...merged['style'], ...ps['style'] };
} else if (key === 'className') {
merged['className'] = [merged['className'], ps['className']].join(' ').trim();
let newClassname = [merged['className'], ps['className']].join(' ').trim();
const isEmpty = newClassname === null || newClassname === undefined || newClassname === '';

merged['className'] = isEmpty ? undefined : newClassname;
} else if (isFn(value)) {
const fn = merged[key];

Expand Down

0 comments on commit a5f2cda

Please sign in to comment.