Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Coachmarks now properly animate when used in any of the center positions",
"packageName": "@fluentui/react",
"email": "mgodbolt@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ export function useHeightOffset(
/**
* Tracks the current height offset and updates during
* the height animation when props.finalHeight is specified.
* State stored as object to ensure re-render even if the value does not change.
* See https://github.com/microsoft/fluentui/issues/23545
*/
const [heightOffset, setHeightOffset] = React.useState<number>(0);
const [heightOffset, setHeightOffset] = React.useState<{ value: number }>({ value: 0 });
const async = useAsync();
const setHeightOffsetTimer = React.useRef<number>(0);

Expand All @@ -278,7 +280,7 @@ export function useHeightOffset(
const cardCurrHeight: number = positioningContainerMainElem.offsetHeight;
const scrollDiff: number = cardScrollHeight - cardCurrHeight;

setHeightOffset(heightOffset + scrollDiff);
setHeightOffset({ value: heightOffset.value + scrollDiff });

if (positioningContainerMainElem.offsetHeight < finalHeight) {
setHeightOffsetEveryFrame();
Expand All @@ -292,7 +294,7 @@ export function useHeightOffset(
// eslint-disable-next-line react-hooks/exhaustive-deps -- should only re-run if finalHeight changes
React.useEffect(setHeightOffsetEveryFrame, [finalHeight]);

return heightOffset;
return heightOffset.value;
}

export const PositioningContainer: React.FunctionComponent<IPositioningContainerProps> = React.forwardRef<
Expand Down