Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jossh88 opened this issue Jul 20, 2021 · 5 comments

Comments

@jossh88
Copy link

jossh88 commented Jul 20, 2021

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}
    />
  );
};
@jossh88 jossh88 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 Jul 20, 2021
@janyin
Copy link

janyin commented Jul 26, 2021

I have the same problem too

@rjtubera
Copy link

same

1 similar comment
@petrosv91
Copy link

same

@janyin
Copy link

janyin commented Dec 10, 2021

22

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

@SewaB
Copy link

SewaB commented Mar 28, 2023

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants