Skip to content

[Fix] #0048244 UI/Prompt: async state roundtrips can break client JS (forms / scripts / close-redirect) - #11986

Closed
fhelfer wants to merge 2 commits into
ILIAS-eLearning:trunkfrom
fhelfer:ui/fix-prompt-async-client
Closed

fhelfer wants to merge 2 commits into
ILIAS-eLearning:trunkfrom
fhelfer:ui/fix-prompt-async-client

Conversation

@fhelfer

@fhelfer fhelfer commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
  • Hardens Prompt JS for asynchronous state roundtrips (null-safe state sections, script replace marker, safer re-init / signal rebinding).
  • Standalone bugfix; unrelated to confirmation / entity-input work.
    Fixes: https://mantis.ilias.de/view.php?id=48244

@fhelfer fhelfer added bugfix javascript Pull requests that update Javascript code labels Aug 26, 2026

@thibsy thibsy left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fhelfer,

Thx a lot for the bugfix!

Please help me answer the following questions:

  • Do I understand correctly that this addresses two separate issues? One being the availability of all sections which is not always the case, the other being the JS code that is provided async that is not always or ever considered?
  • Could you look into whether we could replace the approach used inside the prompt JS using the DOMParser with the AsyncRenderer implementation of the UI framework? This should already take care of the scripts issue I think.

Thx for following up here.

Kind regards,
@thibsy (as UI coordinator)

@fhelfer

fhelfer commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @thibsy,

Thanks for the review.

[x] Do I understand correctly that this addresses two separate issues? One being the availability of all sections which is not always the case, the other being the JS code that is provided async that is not always or ever considered?

Yes, this addresses two separate issues:

  1. Prompt states do not always contain every section. Close and redirect responses omit title, contents and buttons, so the client must tolerate missing sections.
  2. Onload JavaScript from renderAsync() (script[data-replace-marker="script"]) was not executed after an async roundtrip. Button signals and the close handler live in that script, so clicks did nothing. Re-running that script also needs two prompt-specific adjustments: skip a nested il.UI.prompt.init(...), and retarget $(this).trigger('il_signal_…') to document, because the script is no longer evaluated in the component’s own context.

I replaced the DOMParser approach with AsyncRenderer. loadContent() now accepts RequestInit, because prompt forms POST a FormData body and a GET-only fetch would drop that. AsyncRenderer also keeps data-replace-marker on restored script tags. Without that attribute the prompt cannot find the onload script, and the buttons stay inert.

Kind regards, @fhelfer

@fhelfer
fhelfer requested a review from thibsy September 24, 2026 11:19
DOMParser entfällt. Fetch-Optionen bleiben für Formular-POSTs erhalten,
data-replace-marker an wiederhergestellten Scripts ebenfalls.
@thibsy

thibsy commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

This is part of #12303 now, so I close this one.

@thibsy thibsy closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix javascript Pull requests that update Javascript code kitchen sink

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants