import getClosestScrollable from "./get-closest-scrollable";
import { warning } from "../../dev-warning";

const checkForNestedScrollContainer = (scrollable) => {
  if (!scrollable) {
    return;
  }
  const anotherScrollParent = getClosestScrollable(scrollable.parentElement);
  if (!anotherScrollParent) {
    return;
  }
  warning(`
    Droppable: unsupported nested scroll container detected.
    A Droppable can only have one scroll parent (which can be itself)
    Nested scroll containers are currently not supported.

    We hope to support nested scroll containers soon: https://github.com/atlassian/react-beautiful-dnd/issues/131
  `);
};

// We currently do not support nested scroll containers
// But will hopefully support this soon!
export default checkForNestedScrollContainer;
