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

fix: [DHIS2-15383] align mandatory behaviour for all value types #3413

Merged
merged 61 commits into from
Nov 10, 2023

Conversation

superskip
Copy link
Contributor

@superskip superskip commented Sep 13, 2023

Jira: DHIS2-15383

The first three commits are completely independent of each other, so I recommend viewing them separately.

The first commit is a bit complex, so let me break it down a bit:

It concerns itself with a home-made low-level component, acting as a container for a collection of checkboxes.
This component supports keyboard input: arrow keys to move between checkboxes, enter/space to select a checkbox.
However, the original implementation didn't properly handle the case when a key is being held down over time.
The new file withKeyboardNavigation aims to improve the handling in this situation.

Another central feature of this commit is that it introduces an array of refs to the checkboxes.
These are used to keep the container from validating when the focus moves within it (which typically happens when an arrow key is pressed).

The third commit doesn't really address the reported issue, but it is sort of related in that it also contributes to alignment of the behaviour of all fields, specifically the result of d2:hasValue in the rule engine.

All the subsequent commits are only minor adjustments needed for passing the cypress tests.

 - Trigger validation whenever focus leaves component
 - Ignore key events fired by held-down keys
 - Option sets
 - Organisation unit field
 - User name field
 - File selector button
 - Image selector button
Makes `d2:hasValue` work on the relevant fields
@superskip superskip requested a review from a team as a code owner September 13, 2023 16:29
Copy link
Member

@JoakimSM JoakimSM left a comment

Choose a reason for hiding this comment

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

Some minor stuff in addition to what we talked about in person.

@@ -0,0 +1,37 @@
// @flow
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this file to internal/SelectionBoxes? (With the managedKeys it is quite coupled to it and we can make something reusable later if we need to)

};

let ignoreFlag = false;
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment about this flag for future reference?

event.preventDefault();
return;
}
if (event.key == keys.TAB) {
Copy link
Member

Choose a reason for hiding this comment

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

===?

superskip and others added 23 commits October 27, 2023 15:02
- Relocate withKeyboardNavigation.js
- Add comment to ignoreFlag variable
- Fix equality check typo
## [100.35.8](v100.35.7...v100.35.8) (2023-08-22)

### Bug Fixes

* [DHIS2-15492] transition of tooltip enabled state ([#3381](#3381)) ([adb6b32](adb6b32))
## [100.35.9](v100.35.8...v100.35.9) (2023-08-22)

### Bug Fixes

* [DHIS2-15700] Option sets not working in TEI Registration ([2e47477](2e47477))
# [100.36.0](v100.35.9...v100.36.0) (2023-08-22)

### Features

* [DHIS2-15229] search for MULTI_TEXT ([#3395](#3395)) ([c5d9a7d](c5d9a7d))
# [100.37.0](v100.36.0...v100.37.0) (2023-08-22)

### Features

* [DHIS2-15299] escape value for attribute filter ([#3403](#3403)) ([5db743e](5db743e))
# [100.38.0](v100.37.0...v100.38.0) (2023-09-06)

### Features

* [DHIS2-14334] edit enrollment date ([#3350](#3350)) ([9dd1b6a](9dd1b6a))
# [100.39.0](v100.38.0...v100.39.0) (2023-09-07)

### Features

* [DHIS2-13343] hidden program stage rule effect ([#3406](#3406)) ([4ef2973](4ef2973))
## [100.39.1](v100.39.0...v100.39.1) (2023-09-13)

### Bug Fixes

* **translations:** sync translations from transifex (master) ([0fab0eb](0fab0eb))
## [100.39.2](v100.39.1...v100.39.2) (2023-09-14)

### Bug Fixes

* **translations:** sync translations from transifex (master) ([c17c663](c17c663))
## [100.39.3](v100.39.2...v100.39.3) (2023-09-14)

### Bug Fixes

* [DHIS2-15356] change tei search parameter from `ou` to `orgUnit` ([#3362](#3362)) ([c7ab828](c7ab828))
## [100.39.4](v100.39.3...v100.39.4) (2023-09-19)

### Bug Fixes

* **translations:** sync translations from transifex (master) ([712b56e](712b56e))
@superskip superskip requested review from a team as code owners October 27, 2023 18:05
@superskip
Copy link
Contributor Author

The merge I did from master accidentally got split up into several commits during a rebasing operation..

@JoakimSM - I fixed the keyboard navigation problem and the file selector button problem that you showed me, as well as correcting what you pointed out in the comments.

@superskip superskip requested a review from JoakimSM October 27, 2023 18:16
Copy link
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

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

Hey @superskip,
The mandatory error is not displayed when leaving a field with value type MULTI_TEXT (probably some logic is missing in MultiSelectField.component.js).
In addition, after submitting the form, the required error text is displayed, but the field background is not red. Can take a look?

Screen.Recording.2023-10-31.at.11.37.54.mov

Besides this, the rest looks great. Thanks!

@superskip
Copy link
Contributor Author

Thanks for the review @simonadomnisoru !
I ended up wrapping MultiSelecFieldUI in a div and get a lot of line changes because of increased indentation 😐
Possibly it would have been better to change the UI library component so that it calls the onBlur prop when tabbing out.

Copy link
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@JoakimSM JoakimSM left a comment

Choose a reason for hiding this comment

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

nice

Copy link

github-actions bot commented Nov 3, 2023

Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

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

Tested successfully on 2.41,2.40.2,2.39.4,2.38.6 versions

@superskip superskip merged commit b0eddc7 into master Nov 10, 2023
37 checks passed
@superskip superskip deleted the DHIS2-15383 branch November 10, 2023 19:53
dhis2-bot added a commit that referenced this pull request Nov 10, 2023
## [100.44.4](v100.44.3...v100.44.4) (2023-11-10)

### Bug Fixes

* [DHIS2-15383] align mandatory behaviour for all value types ([#3413](#3413)) ([b0eddc7](b0eddc7))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.44.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

7 participants