Refactor FormSteps message handling to work with generic error#6176
Refactor FormSteps message handling to work with generic error#6176
Conversation
0545e8f to
b6cc6c7
Compare
There was a problem hiding this comment.
the ending backtick on other line is throwing me... would this be approximate the same if we did:
| message = `${t('doc_auth.errors.upload_error')} ${t('errors.messages.try_again') | |
| .split(' ') | |
| .join(NBSP_UNICODE)}`; | |
| message = `${t('doc_auth.errors.upload_error')} ${t('errors.messages.try_again')}` | |
| .split(' ') | |
| .join(NBSP_UNICODE); |
There was a problem hiding this comment.
would this be approximate the same if we did:
No, since that would create non-breaking spaces between every word in the error message. The idea with the NBSP is to make sure that "Please try again" stays or breaks onto a new line, but importantly it stays together (see before/after screenshots in #4773). Applying it to the whole string would probably prevent any line breaks altogether.
Maybe what we could do is something like:
| message = `${t('doc_auth.errors.upload_error')} ${t('errors.messages.try_again') | |
| .split(' ') | |
| .join(NBSP_UNICODE)}`; | |
| const tryAgain = t('errors.messages.try_again').split(' ').join(NBSP_UNICODE); | |
| message = `${t('doc_auth.errors.upload_error')} ${tryAgain}`; |
?
There was a problem hiding this comment.
Ah! Yes, this new option makes a lot more sense
There was a problem hiding this comment.
Went a slightly different direction in c0102bf, but same effect of keeping the template string on a single line.
f039def to
2debca9
Compare
**Why**: Since we plan to use FormSteps outside the context of document capture for FlowStateMachine v2, it shouldn't be so strongly aware of specific error types (via FormErrorMessage). The previous implementation was also largely motivated by the inability to translate strings outside the context of a React context, which is no longer the case. [skip changelog]
c0102bf to
38e5bce
Compare
Why: Since we plan to use FormSteps outside the context of document capture for FlowStateMachine v2, it shouldn't be so strongly aware of specific error types (via FormErrorMessage). The previous implementation was also largely motivated by the inability to translate strings outside the context of a React context, which is no longer the case.