change event handler from onSelect to onClose for capturing clear button
build code