Skip to content

Commit

Permalink
fix: use actual default translation keys if not provided explicitly t…
Browse files Browse the repository at this point in the history
…o useModal
  • Loading branch information
dziraf committed Aug 13, 2024
1 parent 1a1e1a4 commit 3a3961c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/frontend/hooks/use-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ export const useModal = (): ModalFunctions => {
buttons.push({ label: translateButton('ok', resourceId), variant: 'primary', onClick: closeModal })
}

const getDefaultTranslationKey = (placement: string) => `modal-${placement}`

const data: ModalData = {
modalProps: {
...modalProps,
label: translateLabel(modalProps.label || '', resourceId),
title: translateMessage(modalProps.title || '', resourceId),
subTitle: translateMessage(modalProps.subTitle || '', resourceId),
label: translateLabel(modalProps.label || getDefaultTranslationKey('label'), resourceId),
title: translateMessage(modalProps.title || getDefaultTranslationKey('title'), resourceId),
subTitle: translateMessage(modalProps.subTitle || getDefaultTranslationKey('subTitle'), resourceId),
variant: modalProps.variant,
buttons,
onClose: modalProps.onClose || closeModal,
Expand Down

2 comments on commit 3a3961c

@malteamlimit
Copy link

@malteamlimit malteamlimit commented on 3a3961c Sep 4, 2024

Choose a reason for hiding this comment

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

Thanks for the update, but without further documentation it's hard to comprehend other issues.
Since this update, the default deleteAction produces the subtitle "modal-subTitle" in the confirmation modal,
due to the lack of the subtitle parameter (just possible to forward "guard" for modal title) and a default translation key. So it just passes "modal-subTitle" as a String in production.
Would be nice to get more information about context and and a default translation keys :)
And how could I just let the subTitle away without setting the default translation to ''?

Screenshot 2024-09-04 at 09 27 22

@Physium
Copy link

Choose a reason for hiding this comment

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

this looks like a bug 100%, should probably create an issue

Please sign in to comment.