import SearchElement from "./element.js";
import Search, {MENU_SEARCH_SELECTOR} from "./search.js";

/**
 * The "Find" button on the site menu search.
 * @see Search
 */
export default class SearchButton extends SearchElement {
	/**
	 * @param {Search} search
	 */
	constructor(search) {
		super(search, document.querySelector(`${MENU_SEARCH_SELECTOR} > a`));
		
		this.elem.addEventListener('click', e =>{
			// Avoid collapsing the menu on button click.
			e.stopPropagation(); 
			this.onClick();
		});
	}
	async onClick() {
		await this.search.toggleActive();
	}
}