Caution, this is not a simple issue to work on, its category of "normal" is not the difficulty, but
a measure of its impact →
.
Problem/Motivation
Image fields have a Title and Alt sub-fields. Both sub-fields are optional and translatable, but enabling/disabling each sub-field does not show/hide the corresponding translation controls. This is confusing, especially because Alt is enabled by default, but Title is not.
Proposed resolution
- When editing an image field, use Form API states to hide the Alt checkbox in the Translatable elements list when the Enable Alt field checkbox is unchecked.
- When editing an image field, use Form API states to hide the Title checkbox in the Translatable elements list when the Enable Title field checkbox is unchecked.
- When editing an image field, display a message ("Disabled fields are not shown. Please first enable the fields you need to make translatable.") below the Translatable elements list if any Translatable elements checkboxes are being hidden.
- On the Content language settings page at
admin/config/regional/content-language
, hide the Alt checkbox if Enable Alt field is unchecked.
- On the Content language settings page at
admin/config/regional/content-language
, hide the Title checkbox if Enable Title field is unchecked.
- On the Content language settings page, display a message ("Disabled fields are not shown. Please first enable the fields you need to make translatable.") if any checkboxes are being hidden.
Note that testbot cannot run front-end tests automatically (see
#2232271: [Meta] Use Behat for validation testing →
or
#2229187: SiteEffect: Automated frontend regression testing →
, also
#825436: Create selenium-RC PIFR plugin for full functional testing →
).
Aside: should this issue be split into two?
It's been suggested the issue be split into two issues: one to change the image field edit page, and one to change the Content language page.
The problem with splitting into two issues is that whichever one is fixed first might be broken by trying to fix the other, and we wouldn't know because we don't have tests (this happened at some point in working on this issue).
Remaining tasks
- Decide whether to postpone this issue until we have automatic front-end tests.
- Write front-end tests.
- Show/hide checkboxes on the image field edit page, and announce this to screenreaders.
- Show/hide checkboxes on the Content language settings page, and announce this to screenreaders.
- Display a warning when checkboxes are being hidden on the Content language settings page.
- Usability review.
Steps to reproduce
- Install a fresh Drupal 8.0 site using the Standard install profile (
drush -y site-install standard
).
- Enable the Content Translation module (
drush -y pm-enable content_translation
).
- Go to
admin/config/regional/language
and add a second language.
- Go to
admin/structure/types/manage/article/fields/node.article.field_image
.
- There is a checkbox labeled "Enable Alt field". It is checked by default.
- There is a checkbox group titled "Translatable elements", containing a checkbox labeled "Alt". It is checked by default.
- There is a checkbox labeled "Enable Title field". It is unchecked by default.
- Expected behavior:
- There is no checkbox labeled "Title" in the "Translatable elements" checkbox group. There is a message saying "Disabled fields are not shown. First enable the fields before changing their translatable setting."
- Actual behavior:
- There is a checkbox group titled "Translatable elements", containing a checkbox labeled "Title". It is checked by default.
- Uncheck the checkbox labeled "Enable Alt field".
- Expected behavior:
- The checkbox labeled "Alt" in the "Translatable elements" checkbox group disappears.
- The message "Disabled fields are not shown. First enable the fields before changing their translatable setting." stays visible.
- Actual behavior:
- The checkbox labeled "Alt" in the "Translatable elements" checkbox group stays visible.
- No message is shown.
- Check the checkbox labeled "Enable Alt field".
- Expected behavior:
- A checkbox labeled "Alt" in the "Translatable elements" checkbox group appears. It is checked by default.
- The message "Disabled fields are not shown. First enable the fields before changing their translatable setting." stays visible.
- Actual behavior:
- The checkbox labeled "Alt" in the "Translatable elements" checkbox group stays visible.
- No message is shown.
- Check the checkbox labeled "Enable Title field".
- Expected behavior:
- A checkbox labeled "Title" in the "Translatable elements" checkbox group appears. It is checked by default.
- The message "Disabled fields are not shown. First enable the fields before changing their translatable setting." disappears.
- Actual behavior
- The checkbox labeled "Title" in the "Translatable elements" checkbox group remains visible.
- No message is shown.
- Uncheck the checkbox labeled "Enable Title field".
- Expected behavior:
- The checkbox labeled "Title" in the "Translatable elements" checkbox group disappears.
- The message "Disabled fields are not shown. First enable the fields before changing their translatable setting." appears.
- Actual behavior
- The checkbox labeled "Title" in the "Translatable elements" checkbox group remains visible.
- No message is shown.
- Check the checkbox labeled "Enable Title field".
- Click
Save configuration
.
- Go to
admin/config/regional/content-language
. In the Custom language settings checkbox group, check Content
. In the Content table, check the Translatable
checkbox for the Article content type.
- A list of fields available for translation appears.
- Under "Article" -> "Image", the "File" checkbox is unchecked.
- Under "Article" -> "Image", the "Alt" checkbox is checked.
- Under "Article" -> "Image", the "Title" checkbox is checked.
- No message is shown.
- Go to
admin/structure/types/manage/article/fields/node.article.field_image
.
- Uncheck the checkbox labeled "Enable Title field".
- Uncheck the checkbox labeled "Enable Alt field".
- Click
Save configuration
.
- Go to
admin/config/regional/content-language
. In the Custom language settings checkbox group, check Content
. In the Content table, check the Translatable
checkbox for the Article content type.
- A list of fields available for translation appears.
- Under "Article" -> "Image", the "File" checkbox is unchecked.
- Expected behavior:
- Under "Article" -> "Image", there is no "Alt" checkbox.
- Under "Article" -> "Image", there is no "Title" checkbox.
- The message "Disabled fields are not shown. First enable the fields before changing their translatable setting." is shown.
- Actual behavior:
- Under "Article" -> "Image", the "Alt" checkbox is checked.
- Under "Article" -> "Image", the "Title" checkbox is checked.
- No message is shown.
User interface changes
- When editing image field settings:
- Hide the Alt checkbox in the Translatable elements list when the Enable Alt field checkbox is unchecked.
- Hide the Title checkbox in the Translatable elements list when the Enable Title field checkbox is unchecked.
- Display a message when a checkbox is being hidden from the Translatable elements list.
- On the Content language settings page:
- Hide the Alt checkbox in the list of fields when the Enable Alt field checkbox is unchecked in the field settings.
- Hide the Title checkbox in the list of fields when the Enable Title field checkbox is unchecked in the field settings.
- Display a message when a checkbox is being hidden from the list of fields.
API changes
None.
(If problems are discovered in the config storage, that will be filed in a separate issue)