import React from 'react';
import { Drawer } from '@alifd/next';
import { LayoutContext } from '../../utils/layout';
import { DrawerProps } from '@alifd/next/types/drawer';

export default class ContextDrawer extends React.Component<DrawerProps> {
  static contextType = LayoutContext;

  render() {
    let { props } = this;
    if (this?.context?.tabId) {
      props = {
        ...props,
        // @ts-ignore
        popupContainer: this.context.tabId,
      };
    }
    return <Drawer {...props} />;
  }
}
