Skip to content
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

Input: required attribute has no effect #3498

Closed
Lukas742 opened this issue Jul 12, 2021 · 2 comments · Fixed by #5133
Closed

Input: required attribute has no effect #3498

Lukas742 opened this issue Jul 12, 2021 · 2 comments · Fixed by #5133
Assignees
Labels
bug This issue is a bug in the code Medium Prio TOPIC Core

Comments

@Lukas742
Copy link
Collaborator

Bug Description

The required attribute has no effect when used in a form.

Expected Behavior

When required is set inside a form, it should not be possible to submit the form if the input field has no value, also it should be possible to validate if the form is valid with checkValidity().

Steps to Reproduce

  1. Go to https://codesandbox.io/s/ui5-webcomponents-forked-6gwbj?file=/index.html
  2. Do not type anything in either of the inputs and then submit the form by clicking the button.
  3. See that only the html button is responding to the required attribute and because of that, the checkValidity() method is returning false.
  4. Type something into the html input field
  5. Click the submit button.
  6. See that the form submits its elements and the checkValidity() method is returning true, even though the "UI5-Input" is required and has no value.

Isolated Example

https://codesandbox.io/s/ui5-webcomponents-forked-6gwbj?file=/index.html

Context

  • UI5 Web Components version: 1.0.0-rc.14

Possible root cause

The required attribute is missing from the hidden input field, generated for form support.
image

This is probably because of these lines:

const copyDefaultProperties = (element, nativeInput) => {
nativeInput.disabled = element.disabled;
nativeInput.value = element.value;
};

Here, only disabled and value are copied to the hidden input element.

@georgimkv georgimkv self-assigned this Jul 12, 2021
@georgimkv georgimkv added bug This issue is a bug in the code TOPIC RL labels Jul 12, 2021
@georgimkv
Copy link
Contributor

Hi @SAP/ui5-webcomponents-topic-rl ,

This issue is well described - ui5-input with attribute required does not work with formElement.checkValidity().
Would you take a look?

Kind regards,
Georgi

@georgimkv georgimkv removed their assignment Jul 12, 2021
@niyap niyap self-assigned this Jul 21, 2021
@vladitasev vladitasev self-assigned this Jul 28, 2021
@vladitasev
Copy link
Contributor

This is related to the form support feature. I'll have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug in the code Medium Prio TOPIC Core
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

6 participants