Tested the MR on Drupal 10.3.5 and it works perfectly fine.
Thanks @Omega_yang and @arturs.v for the great work!
I took a look at Drupal core and noticed the following MR created for issue #2253257 📌 Use a modal for entity delete operation links Fixed (Use a modal for entity delete operation links):
https://git.drupalcode.org/project/drupal/-/merge_requests/3700/diffs#8d...
And, here is the merged commit for that issue:
https://github.com/drupal/drupal/commit/bab4e14492b807364137f4b4075c86cb...
Hope it helps.
Thanks for taking a look at the issue so quickly. I gave the patch a try but unfortunately the issue still exists. It seems that array field $build['#attached']['library'] already exists as a string (and thus it won't be overidden). Here is a customized change I made:
public static function attachLibraries(array &$build) {
$build += ['#attached' => []];
$build['#attached'] += ['library' => []];
file_put_contents(__DIR__ . 'log.txt', var_export($build['#attached'], true));
// ...
}
The log contains the following:
array (
'library' => 'core/drupal.dialog.ajax',
)