Fix countdown JavaScript error for lockout screens#6129
Conversation
**Why**: So we don't have any errors, and so that the countdown counts down as expected.
because it's different instance than when presenter is constructed in controller, so calling to enqueue scripts must be on same instance b/w component render and view render
| <% end %> | ||
|
|
||
| <% Array(presenter.description).each do |description_p| %> | ||
| <% Array(presenter.description(self)).each do |description_p| %> |
There was a problem hiding this comment.
I don't like it, and we encountered it once before in #6023 (comment), but as noted in extended commit description of dcef566 and original pull request comment text, we can't rely on view_context remaining constant between the time of presenter initialization and view rendering (source, related issue). The value of view_context in a constructed presenter may receive scripts to enqueue associated with the component, but those scripts would not be the same as rendered into the template. We sorta avoided this in #6023 because the presenter was constructed inside a helper, so view rendering had already begun, and the render-bound view_context was available.
I think an ideal long-term solution is to remove these presenters and views altogether, then create a shared "Failure" component that can take the place of this view and the idv/shared/_error.html.erb partial, then each failure type can have a dedicated view that calls directly to the component.
e.g.
<%# app/views/shared/_otp_max_attempts %>
<%= render ErrorPageComponent.new(...) %>changelog: Bug Fixes, Account Locked, Fix JavaScript error and countdown on account locked screen
Regression of #6023
Why: So we don't have any errors, and so that the countdown counts down as expected.
NR: https://onenr.io/0BQ1AyEdAQx
Draft: Need to resolve issue where scripts associated with the view component aren't being printed. Initial degugging shows thatEdit: In dcef566, view context is passed directly from view. See related comment at #6129 (comment).view_contextpassed to presenter is distinct from rendering template, thus maybe not printing scripts added through associated script helper (see similar issue).