Focus indicates the element that receives keyboard actions. Its visual indicator must always remain visible, never removed without an equivalent. In a dynamic interface such as a dialog, you move focus on opening, keep it trapped inside the modal window, then restore it on closing.
Example
dialog.showModal();
bouton.focus();