AJAX doesn't work in custom form element
I believe you may need this syntax as your callback, I think because everything went to being 'static' when you moved your demo code from a form to a Element.

 $btnSendCode = [
  '#type' =&gt; 'ajax_button',
  '#value' =&gt; $element['#btnSendCodeTitle'],
  '#ajax' =&gt; [                  
    'callback' =&gt; ['\Drupal\aqr_basic\Element\EmailElement', 'email'],
    'event' =&gt; 'click',
  ],
];