Redirect after form submit to current url

if you have your form node/add in a modal and you want to redirect to current page after form submit in modal window

function YOURMODULENAME_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'YOURFORMID') {
    foreach (array_keys($form['actions']) as $action) {
      if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
        $form['actions'][$action]['#submit'][] = 'callback_source_submit';
      }
    }
  }
}

function callback_source_submit($form, FormStateInterface $form_state) {
    $nid = Drupal::request()->query->get('nid');
    $form_state->setRedirect('entity.node.canonical',
        array('node' => $nid));
}
Drupal version: 


Source: https://www.drupal.org/taxonomy/term/22/feed