Files
threshold-ui/addons/rose/addon/modifiers/on-click-inside.js
T
Zhihe Li b722fa361b * feat: 🎸 Add code-editor component (#1207)
* feat: 🎸 Add code-editor component

Added code editor component which was taken from HCP, tweaked styles and
imports to use boundary assets

✅ Closes: ICU-5167
2022-07-29 17:18:07 -04:00

21 lines
537 B
JavaScript

import { modifier } from 'ember-modifier';
/**
* Used to detect clicks occurring _inside_ the modified element.
* This is useful especially for dropdowns to toggle content visibility
* when the user clicks an item.
*/
export default modifier((element, [callback]) => {
function handleClick(event) {
if (element.contains(event.target)) {
callback(element, event);
}
}
element.addEventListener('click', handleClick, false);
return () => {
element.removeEventListener('click', handleClick, false);
};
});