diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java index 42f56f1a31aa..30fc5adbeb6a 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java @@ -293,6 +293,12 @@ public void displayCustom(StringBuffer buffer, String fieldName, String prefix, ScriptContext.ENGINE_SCOPE); scontext.setAttribute("object", new com.xpn.xwiki.api.Object(object, context), ScriptContext.ENGINE_SCOPE); scontext.setAttribute("type", type, ScriptContext.ENGINE_SCOPE); + /* This is a text alternative fallback to explain what the input is about. + If the input has already been labelled in another way, this fallback will be ignored by Assistive Techs. + */ + scontext.setAttribute("aria-label", + localizePlainOrKey("core.model.xclass.editClassProperty.textAlternative", + this.getTranslatedPrettyName(context)), ScriptContext.ENGINE_SCOPE); BaseProperty prop = (BaseProperty) object.safeget(fieldName); if (prop != null) { diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java index 4fa41961b5f6..52bc705df78a 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java @@ -111,6 +111,11 @@ public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCol input.setID(prefix + name); input.setSize(getSize()); input.setDisabled(isDisabled()); + /* This is a text alternative fallback to explain what the input is about. + If the input has already been labelled in another way, this fallback will be ignored by Assistive Techs. + */ + input.addAttribute("aria-label", localizePlainOrKey("core.model.xclass.editClassProperty.textAlternative", + this.getTranslatedPrettyName(context))); if (isPicker()) { displayPickerEdit(input); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties index 5e39c4ab3554..73a15beb39f5 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties @@ -601,6 +601,7 @@ core.importer.saveDocumentComment=Imported from XAR core.importer.securitySettingsChanged=Security settings have changed during the import. You will need to authenticate in order to continue to administrate the wiki. core.importer.importAsBackup=Import as backup package +core.model.xclass.editClassProperty.textAlternative=Edit the property "{0}". core.model.xclass.deleteClassProperty.versionSummary=Removed class property "{0}" core.model.xclass.disableClassProperty.versionSummary=Disabled class property "{0}" core.model.xclass.enableClassProperty.versionSummary=Enabled class property "{0}" diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/api/ContextTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/api/ContextTest.java index f4fec3ae9b28..4d5a0f01c6da 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/api/ContextTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/api/ContextTest.java @@ -73,7 +73,7 @@ void setDisplayMode() throws Exception context.setDisplayMode("edit"); // We verify that the result contains a form input - assertEquals("", + assertEquals("", document.display("prop", xcontext)); assertEquals("edit", context.getDisplayMode()); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java index d22d62320eb7..8d3307b65889 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java @@ -597,7 +597,7 @@ public void display() this.document.setSyntax(Syntax.XWIKI_2_0); assertEquals( - "{{html clean=\"false\" wiki=\"false\"}}{{/html}}", + "{{html clean=\"false\" wiki=\"false\"}}{{/html}}", this.document.display("string", "edit", this.oldcore.getXWikiContext())); assertEquals("string", this.document.display("string", "view", this.oldcore.getXWikiContext())); @@ -633,7 +633,7 @@ public void display1020() assertEquals("string", this.document.display("string", "view", this.oldcore.getXWikiContext())); assertEquals( - "{pre}{/pre}", + "{pre}{/pre}", this.document.display("string", "edit", this.oldcore.getXWikiContext())); assertEquals("
area
", this.document.display("area", "view", this.oldcore.getXWikiContext())); @@ -650,7 +650,7 @@ public void displayTemplate20() assertEquals("string", this.document.display("string", "view", this.oldcore.getXWikiContext())); assertEquals( - "", + "", this.document.display("string", "edit", this.oldcore.getXWikiContext())); assertEquals("area
", this.document.display("area", "view", this.oldcore.getXWikiContext())); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/PropertyClassTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/PropertyClassTest.java index 1197cc43b351..128e7b0db5a0 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/PropertyClassTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/PropertyClassTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xwiki.localization.ContextualLocalizationManager; import org.xwiki.model.reference.DocumentReference; import org.xwiki.model.reference.DocumentReferenceResolver; import org.xwiki.model.reference.EntityReferenceSerializer; @@ -77,6 +78,7 @@ public void before() throws Exception this.oldCore.getMocker().registerMockComponent(EntityReferenceSerializer.TYPE_STRING, "compactwiki"); this.oldCore.getMocker().registerMockComponent(DocumentReferenceResolver.TYPE_STRING, "currentmixed"); this.oldCore.getMocker().registerMockComponent(EntityReferenceSerializer.TYPE_STRING, "local"); + this.oldCore.getMocker().registerMockComponent(ContextualLocalizationManager.class); } /** Test the {@link PropertyClass#compareTo(PropertyClass)} method. */ diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/StringClassTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/StringClassTest.java index e3cf4987f6be..952c506e63a9 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/StringClassTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/objects/classes/StringClassTest.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mock; +import org.xwiki.localization.ContextualLocalizationManager; import org.xwiki.model.reference.DocumentReference; import org.xwiki.model.reference.LocalDocumentReference; @@ -50,8 +51,11 @@ class StringClassTest private XWikiURLFactory urlFactory; @Test - void displayEdit() + void displayEdit() throws Exception { + // Setup + this.oldCore.getMocker().registerMockComponent(ContextualLocalizationManager.class); + XWikiContext xWikiContext = this.oldCore.getXWikiContext(); xWikiContext.setURLFactory(this.urlFactory); when(this.oldCore.getSpyXWiki() @@ -70,14 +74,14 @@ void displayEdit() StringBuffer stringBuffer = new StringBuffer(); stringClass.displayEdit(stringBuffer, fieldName, spaceName + "." + pageName + "_0_", baseClass, xWikiContext); - assertEquals("", stringBuffer.toString()); } } diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_date.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_date.vm index a422bbeb2207..91e3f015f8d7 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_date.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_date.vm @@ -27,7 +27,8 @@ 'name': $id, 'value': $value, 'disabled': $disabled, - 'data-format': $format + 'data-format': $format, + 'aria-label': $aria-label }) #set ($picker = $field.getProperty('picker').value == 1) #if ($picker)