Всем привет, проблему устранить так и не удалось, привожу полный код. Кнопку динамически создавать не стал, оказывается она и в четко прописанном html не корректно "кликается". Если курсор на иконке или тексте, получаем undefined, если где-то в уголке кнопки - все норм.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TEST</title>
<link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon">
</head>
<style>
html,
body {
margin: 0;
padding: 0;
}
*,
*:before,
*:after {
-webkit-border-sizing: border-box;
-moz-border-sizing: border-box;
box-sizing: border-box;
}
body.vsfm_disable-scroll {
position: relative;
overflow: hidden;
font-family: "Helvetica Neue", "Segoe UI", helvetica, verdana, sans-serif !important;
}
.vsfm_overlay {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
background: rgba(0, 0, 0, .5);
}
.vsfm_modal {
display: flex;
flex-direction: column;
width: clamp(300px, 90%, 1780px);
height: clamp(300px, 70%, 800px);
margin: 0 auto;
background: #fff;
box-shadow: 0 16px 16px -10px rgba(34, 47, 62, .25), 0 0 40px 1px rgba(34, 47, 62, .25);
position: relative;
}
/* TOOLBAR */
.vsfm_modaltoolbar {
background: #FAFAFA;
padding: 6px 20px;
min-height: 48px;
display: flex;
justify-content: space-between;
align-items: center;
}
.vsfm_modaltoolbar-one {
display: flex;
justify-content: space-between;
align-items: center;
}
.vsfm_control-btn {
display: flex;
align-items: center;
border-radius: 4px;
border-width: 1px;
border-style: solid;
border-color: transparent;
background: #e0e0e0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 7px 18px 8px 18px;
font-family: "Helvetica Neue", "Segoe UI", helvetica, verdana, sans-serif !important;
color: #333;
font-size: .9rem;
cursor: pointer;
text-align: center;
box-sizing: border-box;
}
.vsfm_control-btn:hover {
background: #e4e3e3;
}
.vsfm_control-btn i {
font-style: normal;
font-size: 22px;
padding-right: 8px;
}
</style>
<body class="vsfm_disable-scroll">
<div class="vsfm_overlay">
<div class="vsfm_modal">
<div class="vsfm_modaltoolbar">
<div class="vsfm_modaltoolbar-one">
<button class="vsfm_control-btn" data-command="create">
<i class="icon-create_new_folder">✚</i>
<span class="vsfm_control-btn-text">Создать</span>
</button>
</div>
<div class="vsfm_modaltoolbar-second">
<button class="vsfm_control-btn" data-command="close">
<i class="icon-clear">✖</i>
<span class="vsfm_control-btn-text">Закрыть</span>
</button>
</div>
</div>
</div>
</div>
<script>
let button = document.querySelectorAll('[data-command]')
button.forEach(function(b) {
b.onclick = function(event) {
if (b.disabled) return
let command = event.target.dataset.command
alert(command)
}
})
</script>
</body>
</html>