diff --git a/packages/survey-core/src/question.ts b/packages/survey-core/src/question.ts index 9ce5d1513e..d26fc1c934 100644 --- a/packages/survey-core/src/question.ts +++ b/packages/survey-core/src/question.ts @@ -2765,7 +2765,7 @@ export class Question extends SurveyElement public get ariaDescribedBy(): string { if (this.isNewA11yStructure) return null; - if (this.hasTitle) { + if (this.hasTitle && this.hasDescription) { return this.ariaDescriptionId; } else { return null; @@ -2804,7 +2804,7 @@ export class Question extends SurveyElement } } public get a11y_input_ariaDescribedBy(): string { - if (this.hasTitle && !this.parentQuestion) { + if (this.hasTitle && !this.parentQuestion && this.hasDescription) { return this.ariaDescriptionId; } else { return null; diff --git a/packages/survey-core/tests/a11y.ts b/packages/survey-core/tests/a11y.ts index 6b0bc5736b..504f12e7dd 100644 --- a/packages/survey-core/tests/a11y.ts +++ b/packages/survey-core/tests/a11y.ts @@ -72,6 +72,24 @@ QUnit.test( } ); +QUnit.test( + "a11y: aria-describedbby: empty description", + function(assert) { + var json = { + questions: [ + { + type: "text", + title: "Title", + name: "q1" + }, + ], + }; + var survey = new SurveyModel(json); + var question = survey.getQuestionByName("q1"); + assert.equal(question.a11y_input_ariaDescribedBy, null, "aria-describedbby is null"); + } +); + QUnit.test( "a11y: aria-invalid", function(assert) { diff --git a/tests/markup/snapshots/boolean-disabled.snap.html b/tests/markup/snapshots/boolean-disabled.snap.html index b1287cd3e9..6292efd270 100644 --- a/tests/markup/snapshots/boolean-disabled.snap.html +++ b/tests/markup/snapshots/boolean-disabled.snap.html @@ -1,6 +1,6 @@
diff --git a/tests/markup/snapshots/page-questionTitleWidth.snap.html b/tests/markup/snapshots/page-questionTitleWidth.snap.html index d1856decdb..250c96b5d6 100644 --- a/tests/markup/snapshots/page-questionTitleWidth.snap.html +++ b/tests/markup/snapshots/page-questionTitleWidth.snap.html @@ -8,7 +8,7 @@
\ No newline at end of file diff --git a/tests/markup/snapshots/page-swnl-title-v2.snap.html b/tests/markup/snapshots/page-swnl-title-v2.snap.html index 0892b79d75..9474c82d14 100644 --- a/tests/markup/snapshots/page-swnl-title-v2.snap.html +++ b/tests/markup/snapshots/page-swnl-title-v2.snap.html @@ -8,7 +8,7 @@
@@ -22,7 +22,7 @@
\ No newline at end of file diff --git a/tests/markup/snapshots/page-title-v2.snap.html b/tests/markup/snapshots/page-title-v2.snap.html index 8fa7c32719..0a469b2c84 100644 --- a/tests/markup/snapshots/page-title-v2.snap.html +++ b/tests/markup/snapshots/page-title-v2.snap.html @@ -8,7 +8,7 @@
\ No newline at end of file diff --git a/tests/markup/snapshots/panel-page-swnl-title-v2.snap.html b/tests/markup/snapshots/panel-page-swnl-title-v2.snap.html index 636274bcf1..36934f6f98 100644 --- a/tests/markup/snapshots/panel-page-swnl-title-v2.snap.html +++ b/tests/markup/snapshots/panel-page-swnl-title-v2.snap.html @@ -8,7 +8,7 @@
@@ -24,7 +24,7 @@
diff --git a/tests/markup/snapshots/question-errors-v2-bottom.snap.html b/tests/markup/snapshots/question-errors-v2-bottom.snap.html index 5fe159eb1c..61ad7d6349 100644 --- a/tests/markup/snapshots/question-errors-v2-bottom.snap.html +++ b/tests/markup/snapshots/question-errors-v2-bottom.snap.html @@ -10,7 +10,7 @@
\ No newline at end of file