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

XWIKI-22830: CreateWiki: Next step button remains disabled if one fills the wiki identifier before the pretty name #3852

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sereza7
Copy link
Contributor

@Sereza7 Sereza7 commented Jan 29, 2025

Jira URL

https://jira.xwiki.org/browse/XWIKI-22830

Changes

Description

  • Added changes to the next-step button in the prettyName event handler.

Screenshots & Video

In the video demo below, I tried out a bunch of combinations, to show that the state of the button is the right one no matter the operations made by the user on the form. Among them, I showcase that the use case that was failing and reported in the ticket is fixed.

2025-01-29.17-32-23.mp4

Executed Tests

Manual tests, see demo above.
Successfully built the module with a change with the quality profile: mvn clean install -f xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-ui/xwiki-platform-wiki-ui-mainwiki -Pquality

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • 16.10.X, localized changes to solve an issue that's been in XS for a long time.

…ls the wiki identifier before the pretty name

* Added changes to the next-step button in the prettyName event handler.
Copy link
Member

@mflorea mflorea left a comment

Choose a reason for hiding this comment

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

The way we validate the wiki name and pretty name needs to be refactored a bit. My suggestion is to:

  • have a validation function for each field that requires validation; this can be either synchronous (as for wiki pretty name) or asynchronous (as for wiki name); what's important is that each field can be in 3 states: valid, invalid, loading
  • have a function that updates the state of the Next button: enables it only if all fields are in valid state (i.e. no loading and no invalid)
  • a change on a field triggers the validation function for that field which triggers the Next button state update
  • for asynchronous validation functions the practice is usually that when a change is detected:
    • the previously scheduled validation is aborted (usually with clearTimeout or aborting the HTTP request)
    • the field is put in loading state
    • a new validation is scheduled in 500ms or so (to not validate on each keystroke but rather when the user stops typing)

@@ -857,6 +858,7 @@ $xwiki.getURL('XWiki.XWikiPreferences', 'admin', "editor=globaladmin&section
if(prettyName.value.blank()){
$('wikiprettynamevalidation').innerHTML = "$MSG_ERROR_WIKIPRETTYNAMEEMPTY";
prettyName.addClassName('xErrorField');
$('wizard-next').disabled = true;
Copy link
Member

Choose a reason for hiding this comment

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

The wiki name validation is asynchronous, which means we can have this case:

  • the user types a valid wiki name, which triggers a validation HTTP request
  • the network is slow, so the user can clear the wiki pretty name before the validation response is received; this disables the Next button
  • the validation response is received, and the Next button is enabled => the user can move to the next step with an empty wiki pretty name

@@ -866,6 +868,11 @@ $xwiki.getURL('XWiki.XWikiPreferences', 'admin', "editor=globaladmin&section
wikiName.value = prettyName.value.replace(/[^a-zA-Z0-9]/g,'_').toLowerCase();
validateWikiName();
}
// No matter the path, at this point, the wikiName has been already validated.
Copy link
Member

Choose a reason for hiding this comment

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

This is not true, because the wiki name validation is asynchronous. We can have this case:

  • the user types an invalid wiki name, which triggers a validation HTTP request
  • the network is slow, so the user can type the wiki pretty name before the validation response is received; this enables the Next button => the user can move to the next step with an invalid wiki name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants