Skip to content

Commit

Permalink
Merge pull request #5313 from melloware/PR5311
Browse files Browse the repository at this point in the history
Fix #5311: AppendTo should be correct on mount
  • Loading branch information
nitrogenous authored Nov 14, 2023
2 parents 20e6f2a + b64a8b9 commit d9fa7f6
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 10 deletions.
2 changes: 2 additions & 0 deletions components/lib/autocomplete/AutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ export const AutoComplete = React.memo(
if (props.autoFocus) {
DomHandler.focus(inputRef.current, props.autoFocus);
}

alignOverlay();
});

useUpdateEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,8 @@ export const Calendar = React.memo(
overlayRef.current.style.width = DomHandler.getOuterWidth(overlayRef.current) + 'px';
}
}
} else {
alignOverlay();
}

if (props.value) {
Expand Down
7 changes: 4 additions & 3 deletions components/lib/cascadeselect/CascadeSelect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { PrimeReactContext } from '../api/Api';
import PrimeReact, { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
Expand All @@ -8,8 +9,6 @@ import { Portal } from '../portal/Portal';
import { DomHandler, IconUtils, ObjectUtils, UniqueComponentId, ZIndexUtils, mergeProps } from '../utils/Utils';
import { CascadeSelectBase } from './CascadeSelectBase';
import { CascadeSelectSub } from './CascadeSelectSub';
import PrimeReact from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';

export const CascadeSelect = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -270,6 +269,8 @@ export const CascadeSelect = React.memo(
if (props.autoFocus) {
DomHandler.focus(inputRef.current, props.autoFocus);
}

alignOverlay();
});

React.useEffect(() => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/colorpicker/ColorPicker.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as React from 'react';
import { PrimeReactContext } from '../api/Api';
import PrimeReact, { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useEventListener, useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { OverlayService } from '../overlayservice/OverlayService';
import { Tooltip } from '../tooltip/Tooltip';
import { DomHandler, ObjectUtils, ZIndexUtils, classNames, mergeProps } from '../utils/Utils';
import { DomHandler, ObjectUtils, ZIndexUtils, mergeProps } from '../utils/Utils';
import { ColorPickerBase } from './ColorPickerBase';
import { ColorPickerPanel } from './ColorPickerPanel';
import PrimeReact from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';

export const ColorPicker = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -515,6 +514,8 @@ export const ColorPicker = React.memo(
if (props.autoFocus) {
DomHandler.focus(inputRef.current, props.autoFocus);
}

alignOverlay();
});

useUpdateEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ export const Dropdown = React.memo(
if (props.autoFocus) {
DomHandler.focus(focusInputRef.current, props.autoFocus);
}

alignOverlay();
});

useUpdateEffect(() => {
Expand Down
6 changes: 5 additions & 1 deletion components/lib/mention/Mention.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PrimeReact, { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { InputTextarea } from '../inputtextarea/InputTextarea';
import { OverlayService } from '../overlayservice/OverlayService';
import { Portal } from '../portal/Portal';
Expand Down Expand Up @@ -352,6 +352,10 @@ export const Mention = React.memo(
ObjectUtils.combinedRefs(inputRef, props.inputRef);
}, [inputRef, props.inputRef]);

useMountEffect(() => {
alignOverlay();
});

useUpdateEffect(() => {
if (searchingState) {
props.suggestions && props.suggestions.length ? show() : hide();
Expand Down
6 changes: 5 additions & 1 deletion components/lib/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PrimeReact, { FilterService, PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { TimesIcon } from '../icons/times';
import { TimesCircleIcon } from '../icons/timescircle';
Expand Down Expand Up @@ -613,6 +613,10 @@ export const MultiSelect = React.memo(
getInput: () => inputRef.current
}));

useMountEffect(() => {
alignOverlay();
});

React.useEffect(() => {
ObjectUtils.combinedRefs(inputRef, props.inputRef);
}, [inputRef, props.inputRef]);
Expand Down
6 changes: 5 additions & 1 deletion components/lib/password/Password.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useOverlayListener, useUnmountEffect } from '../hooks/Hooks';
import { useMountEffect, useOverlayListener, useUnmountEffect } from '../hooks/Hooks';
import { EyeIcon } from '../icons/eye';
import { EyeSlashIcon } from '../icons/eyeslash';
import { InputText } from '../inputtext/InputText';
Expand Down Expand Up @@ -254,6 +254,10 @@ export const Password = React.memo(
}
}, [isFilled]);

useMountEffect(() => {
alignOverlay();
});

useUnmountEffect(() => {
ZIndexUtils.clear(overlayRef.current);
});
Expand Down
2 changes: 2 additions & 0 deletions components/lib/splitbutton/SplitButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export const SplitButton = React.memo(
if (!idState) {
setIdState(UniqueComponentId());
}

alignOverlay();
});

useUnmountEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions components/lib/treeselect/TreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ export const TreeSelect = React.memo(
if (props.autoFocus) {
DomHandler.focus(focusInputRef.current, props.autoFocus);
}

alignOverlay();
});

useUpdateEffect(() => {
Expand Down

0 comments on commit d9fa7f6

Please sign in to comment.