Skip to content

Commit

Permalink
cherry-pick code to handle 'enter' click from v14
Browse files Browse the repository at this point in the history
  • Loading branch information
iOvergaard committed Oct 17, 2024
1 parent 74a57b0 commit 402672b
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export default class UmbLoginPageElement extends LitElement {

if (!this.#formElement) return;

// We need to listen for the enter key to submit the form, because the uui-button does not support the native input fields submit event
this.#formElement.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
this.#onSubmitClick();
}
});

this.#formElement.onsubmit = this.#handleSubmit;
}

Expand All @@ -53,6 +60,12 @@ export default class UmbLoginPageElement extends LitElement {
const password = formData.get('password') as string;
const persist = formData.has('persist');

if (!username || !password) {
this._loginError = await umbLocalizationContext.localize('auth_userFailedLogin');
this._loginState = 'failed';
return;
}

Check notice on line 68 in src/Umbraco.Web.UI.Login/src/components/pages/login.page.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v13/dev)

ℹ Getting worse: Complex Method

UmbLoginPageElement.handleSubmit increases in cyclomatic complexity from 9 to 11, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
this._loginState = 'waiting';

const response = await umbAuthContext.login({
Expand Down

0 comments on commit 402672b

Please sign in to comment.