Skip to content

rc time picker select dropdown is rendering outside the root element not at the position where i have called timepicker within project #237

Open

Description

@jossh88
export const StyledTimePicker = styled(TimePicker)`
  & .rc-time-picker-panel-combobox {
    display: flex;
  }

  & .rc-time-picker-panel-select {
    flex: 1;
  }
  & .rc-time-picker {
    display: inline-block;
    position: relative;
    box-sizing: border-box;
  }
  & .rc-time-picker * {
    box-sizing: border-box;
  }

  & .rc-time-picker-panel * {
    box-sizing: border-box;
  }
  & .rc-time-picker-panel-inner {
    display: inline-block;
    position: relative;
    outline: none;
    list-style: none;
    font-size: 12px;
    text-align: left;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 5px #ccc;
    background-clip: padding-box;
    border: 1px solid #ccc;
    line-height: 1.5;
  }
  & .rc-time-picker-panel-narrow {
    max-width: 113px;
  }

  & .rc-time-picker-input[disabled] {
    color: #ccc;
    background: #f7f7f7;
    cursor: not-allowed;
  }

  & .rc-time-picker-panel-select-active {
    overflow-y: auto;
  }
  & .rc-time-picker-panel-select::first-of-type {
    border-left: 0;
    margin-left: 0;
  }
  & .rc-time-picker-panel-select:last-child {
    border-right: 0;
  }

  & .rc-time-picker-panel-select li:hover {
    background: #edfaff;
  }
  li.rc-time-picker-panel-select-option-selected {
    background: #f7f7f7;
    font-weight: bold;
  }
  li.rc-time-picker-panel-select-option-disabled {
    color: #ccc;
  }
  li.rc-time-picker-panel-select-option-disabled:hover {
    background: transparent;
    cursor: not-allowed;
  }

  & .rc-time-picker-input {
    ${commonCSS}
    background: #f6f6f6;
    text-decoration: none;
    outline: none;
    box-shadow: none;
    font-family: ${FONT_FAMILY};
    color: ${FONT_COLOR};
    ${thinScroll}
    &:focus {
      border: 1px solid #bfc6ff;
      background: #eff1ff !important;
    }
  }
  & .rc-time-picker-panel {
    z-index: 1070;
    width: 170px;
    position: absolute;
    box-sizing: border-box;
  }
  & .rc-time-picker-panel-select {
    float: left;
    font-size: 12px;
    border: 1px solid #e9e9e9;
    border-width: 0 1px;
    margin-left: -1px;
    box-sizing: border-box;
    width: 56px;
    max-height: 144px;
    overflow-y: auto;
    position: relative;
    ul {
      list-style: none;
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      width: 100%;
    }
    li {
      list-style: none;
      margin: 0;
      padding: 0 0 0 16px;
      width: 100%;
      height: 24px;
      line-height: 24px;
      text-align: left;
      cursor: pointer;
      user-select: none;
    }
  }
`;

interface Iprops {
  onChange: (time: any) => void;
  value: any;
  readOnly?: boolean;
  error?: string;
}

export const CustomTimepicker = (props: Iprops) => {
  const { onChange, value, readOnly, error } = props;
  return (
    <StyledTimePicker
      showSecond={false}
      inputReadOnly={readOnly}
      onChange={onChange}
      value={value}
      placement="bottomLeft"
      clearIcon={false}
    />
  );
};

Activity

  1. changed the title [-]rc time picker select dropdown is rendering outside the root element [/-] [+]rc time picker select dropdown is rendering outside the root element not at the position where i have called timepicker within project[/+] on Jul 20, 2021
  2. janyin commented on Jul 26, 2021

    @janyin

    I have the same problem too

  3. rjtubera commented on Nov 10, 2021

    @rjtubera

    same

  4. petrosv91 commented on Nov 30, 2021

    @petrosv91

    same

  5. janyin commented on Dec 10, 2021

    @janyin

    22

    here are my solution. Wrapped div the component, and give id to it, pass 'getPopupContainer' props to component

  6. SewaB commented on Mar 28, 2023

    @SewaB

    getPopupContainer={triggerNode => triggerNode.parentNode}
    https://stackoverflow.com/a/46030038/10544892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions