Skip to content

fix(ui5-input): aria-required attribute removed #2552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/main/src/ComboBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
placeholder="{{placeholder}}"
?disabled={{disabled}}
?readonly={{readonly}}
?required={{required}}
value-state="{{valueState}}"
@input="{{_input}}"
@change="{{_inputChange}}"
Expand All @@ -23,6 +22,7 @@
aria-autocomplete="both"
aria-describedby="{{valueStateTextId}}"
aria-label="{{ariaLabelText}}"
aria-required="{{required}}"
/>

{{#if icon}}
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/DatePicker.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
type="{{type}}"
value="{{value}}"
?disabled="{{disabled}}"
?required="{{required}}"
?readonly="{{readonly}}"
value-state="{{valueState}}"
@ui5-change="{{_handleInputChange}}"
Expand Down
1 change: 0 additions & 1 deletion packages/main/src/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,6 @@ class DatePicker extends UI5Element {
"ariaOwns": `${this._id}-responsive-popover`,
"ariaExpanded": this.isOpen(),
"ariaDescription": this.dateAriaDescription,
"ariaRequired": this.required,
"ariaLabel": getEffectiveAriaLabelText(this),
};
}
Expand Down
3 changes: 1 addition & 2 deletions packages/main/src/Input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
?inner-input-with-icon="{{icon.length}}"
?disabled="{{disabled}}"
?readonly="{{_readonly}}"
?required="{{required}}"
.value="{{value}}"
placeholder="{{placeholder}}"
maxlength="{{maxlength}}"
Expand All @@ -25,7 +24,7 @@
aria-autocomplete="{{accInfo.input.ariaAutoComplete}}"
aria-expanded="{{accInfo.input.ariaExpanded}}"
aria-label="{{accInfo.input.ariaLabel}}"
aria-required="{{accInfo.input.ariaRequired}}"
Copy link
Member

Choose a reason for hiding this comment

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

I understand the change, but just to note that if we remove that we can also remove the following as it is not used in the template anymore:

// Input.js#1070
"ariaRequired": (this._inputAccInfo && this._inputAccInfo.ariaRequired) || this.required

And, second note - the DatePicker used to pass "accInfo.input.ariaRequired",
so it also should be removed if not necessary:

// DatePicker.js#826
"ariaRequired": this.required,

But then I guess we have to forward the "required" property from the DatePicker to the Input in the DatePicker.hbs template. Otherwise, the Input (in the DatePicker) will remain without both aria-required and required, as it previously used only aria-required and now it is being removed from the Input.hbs template.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We changed the approach. Now only "aria-required" is always added to the input of all input-based components. Also as you have mentioned, we forward the "required" property from the DatePicker to the Input.

aria-required="{{required}}"
@input="{{_handleInput}}"
@change="{{_handleChange}}"
@keydown="{{_onkeydown}}"
Expand Down
1 change: 0 additions & 1 deletion packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,6 @@ class Input extends UI5Element {
"ariaExpanded": this._inputAccInfo && this._inputAccInfo.ariaExpanded,
"ariaDescription": this._inputAccInfo && this._inputAccInfo.ariaDescription,
"ariaLabel": (this._inputAccInfo && this._inputAccInfo.ariaLabel) || getEffectiveAriaLabelText(this),
"ariaRequired": (this._inputAccInfo && this._inputAccInfo.ariaRequired) || this.required,
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/MultiComboBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
placeholder="{{placeholder}}"
?disabled={{disabled}}
?readonly={{readonly}}
?required={{required}}
value-state="{{valueState}}"
@input="{{_inputLiveChange}}"
@change={{_inputChange}}
Expand All @@ -53,6 +52,7 @@
aria-autocomplete="both"
aria-labelledby="{{_id}}-hiddenText-nMore"
aria-describedby="{{valueStateTextId}}"
aria-required="{{required}}"
/>

{{#if icon}}
Expand Down
1 change: 0 additions & 1 deletion packages/main/src/MultiComboBoxPopover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
.value="{{value}}"
inner-input
placeholder="{{placeholder}}"
?required={{required}}
value-state="{{valueState}}"
@input="{{_inputLiveChange}}"
@change={{_inputChange}}
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TextArea.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
placeholder="{{placeholder}}"
?disabled="{{disabled}}"
?readonly="{{readonly}}"
?required="{{required}}"
aria-label="{{ariaLabelText}}"
aria-describedby="{{ariaDescribedBy}}"
aria-required="{{required}}"
maxlength="{{_exceededTextProps.calcedMaxLength}}"
.value="{{value}}"
@input="{{_oninput}}"
Expand Down
1 change: 1 addition & 0 deletions packages/main/test/pages/DatePicker_test_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<ui5-date-picker id="dp8" value="Jan 6, 2015"></ui5-date-picker>
<ui5-date-picker id="dp9" value="today"></ui5-date-picker>
<ui5-date-picker id="dp10" disabled></ui5-date-picker>
<ui5-date-picker id='dp-required' required></ui5-date-picker>
<ui5-date-picker id="dp11"></ui5-date-picker>
<ui5-date-picker id="dp13"></ui5-date-picker>
<ui5-date-picker id="dp16" format-pattern="long"></ui5-date-picker>
Expand Down
12 changes: 12 additions & 0 deletions packages/main/test/specs/DatePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ describe("Date Picker Tests", () => {
assert.ok(!datepicker.hasIcon(), "icon is not displayed");
});

it("required", () => {
datepicker.id = "#dp-required";

assert.ok(datepicker.input.getProperty("required"), "input has required set");
assert.strictEqual(datepicker.innerInput.getAttribute("aria-required"), "true", "Aria-required attribute is set correctly.");

datepicker.root.removeAttribute("required");

assert.notOk(datepicker.input.getProperty("required"), "required property is not set");
assert.strictEqual(datepicker.innerInput.getAttribute("aria-required"), "false", "Aria-required attribute is set correctly.");
});

it("placeholder", () => {
datepicker.root.setAttribute("placeholder", "test placeholder");

Expand Down
3 changes: 2 additions & 1 deletion packages/main/test/specs/Input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe("Attributes propagation", () => {
});

it("Required attribute is propagated properly", () => {
assert.ok(browser.$("#input-required").shadow$(".ui5-input-inner").getAttribute("required"), "Required property was propagated");
assert.strictEqual(browser.$("#input-required").shadow$(".ui5-input-inner").getAttribute("aria-required"), "true", "Aria-required attribute is set correctly");
assert.strictEqual(browser.$("#input-number").shadow$(".ui5-input-inner").getAttribute("aria-required"), "false", "Aria-required attribute is set correctly");
});

it("Type attribute is propagated properly", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/main/test/specs/TextArea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe("Attributes propagation", () => {
});

it("Required attribute is propagated properly", () => {
assert.ok(browser.$("#required-textarea").shadow$("textarea").getAttribute("required"), "Required property was propagated");
assert.strictEqual(browser.$("#required-textarea").shadow$("textarea").getAttribute("aria-required"), "true", "Aria-required attribute is set correctly");
assert.strictEqual(browser.$("#basic-textarea").shadow$("textarea").getAttribute("aria-required"), "false", "Aria-required attribute is set correctly");
});

it("Value attribute is propagated properly", () => {
Expand Down