import React from 'react'
import useFocusScope from '../../accessibility-utils/useFocusScope.js';
import componentCategories from '../../docs-utils/componentCategories.js';
import componentGroups from '../../docs-utils/componentGroups.js';
import propTypes,{ defaultProps } from './RestoreFocus.propTypes.js'


export default function RestoreFocus(props){

    useFocusScope({restoreFocus:true});

    return <React.Fragment>
        { props.children }
    </React.Fragment>
}

/*
export default class RestoreFocus extends React.Component{
    constructor(props){
        super(props);
        this.restoreNodeEle = null;
    }

    componentDidMount(){
        let { restoreFocus } = this.props;
        if(restoreFocus){
            this.restoreNodeEle = document.activeElement;
        }
    }

    componentWillUnmount(){
        requestAnimationFrame(() => {
            if(document.body.contains(this.restoreNodeEle)){
                this.restoreNodeEle.focus();
            }
        })
    }

    render(){
        let { children } = this.props;
        return(
            <React.Fragment>
                { children }
            </React.Fragment>
        )
    }
}*/

RestoreFocus.propTypes = propTypes;
RestoreFocus.defaultProps = defaultProps;

if (__DOCS__) {
    RestoreFocus.docs = {
      componentGroup: componentGroups.Components,
      folderName : componentCategories.Accessibility
    };
}