Skip to content

Commit

Permalink
Merge pull request #417 from jomiq/patch-title-field
Browse files Browse the repository at this point in the history
Fix TitleFieldPanel patching
  • Loading branch information
DiogoMarques29 authored Apr 2, 2024
2 parents 8ea69c4 + d6949d3 commit c8d95c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
10 changes: 6 additions & 4 deletions wagtail_modeltranslation/patch_wagtailadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,27 @@ def _patch_simple_panel(self, model, original_panel):
new_stream_block.meta.required = False
localized_field.stream_block = new_stream_block

if panel_class == TitleFieldPanel and TRANSLATE_SLUGS:
if panel_class == TitleFieldPanel:
if TRANSLATE_SLUGS:
# When a title field is changed its corresponding localized slug may need to
# be updated.
localized_panel = panel_class(
localized_field_name,
targets=[build_localized_fieldname(target, language)
for target in original_panel.targets])
for target in original_panel.targets],
apply_if_live=original_panel.apply_if_live)
elif language == mt_settings.DEFAULT_LANGUAGE:
# Slugs are not translated, so when a title field in the default language is
# updated we must update the slug it is linked to.
localized_panel = panel_class(
localized_field_name,
targets=original_panel.targets)
targets=original_panel.targets,
apply_if_live=original_panel.apply_if_live)
else:
# Slugs are not translated and this title field is in a non-default language.
# There is no slug to link the title to, so the TitleFieldPanel becomes a
# plain FieldPanel.
localized_panel = FieldPanel(localized_field_name)
localized_panel = FieldPanel(localized_field_name, classname="title")
else:
localized_panel = panel_class(localized_field_name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@
.w-panel.title .Draftail-Editor .public-DraftEditor-content,
.w-panel.title input,
.w-panel.title textarea {
color:var(--w-color-primary);
color:var(--w-color-grey-600);
font-size:1.875rem;
font-weight:800;
line-height:1.3;
margin-inline-start:-.375rem;
padding-inline-start:.375rem;
color:var(--w-color-primary);
color:var(--w-color-grey-600);
color:var(--w-color-text-context);
font-size:1.875rem;
font-weight:800;
line-height:1.3;
margin-inline-start:-.375rem;
padding-inline-start:.375rem;
}
.w-panel.title .Draftail-Editor .public-DraftEditor-content:not(:hover, :focus, [aria-invalid=true]),
.w-panel.title input:not(:hover, :focus, [aria-invalid=true]),
.w-panel.title textarea:not(:hover, :focus, [aria-invalid=true]),
.w-panel.title .Draftail-Editor .public-DraftEditor-content:not(:hover, :focus, [aria-invalid=true]),
.w-panel.title input:not(:hover, :focus, [aria-invalid=true]),
.w-panel.title textarea:not(:hover, :focus, [aria-invalid=true]) {
border-color:#0000
border-color:#0000
}

0 comments on commit c8d95c8

Please sign in to comment.