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

@jossh88

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}
    />
  );
};

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