Skip to content

Fix error message from controlled vocabulary fields remaining hidden after user interaction#4502

Open
alexandrevryghem wants to merge 2 commits intoDSpace:mainfrom
alexandrevryghem:w2p-131984_fix-hidden-hierachical-vocabulary-error-message-after-interaction_contribute-main
Open

Fix error message from controlled vocabulary fields remaining hidden after user interaction#4502
alexandrevryghem wants to merge 2 commits intoDSpace:mainfrom
alexandrevryghem:w2p-131984_fix-hidden-hierachical-vocabulary-error-message-after-interaction_contribute-main

Conversation

@alexandrevryghem
Copy link
Member

References

Description

Fixed an issue where onebox fields that use vocabularies don't trigger the onBlur event. This is problematic because error messages are not shown when the field is focused. Because the onBlur event is responsible for setting the hasFocus boolean to false and that onBlur was never triggered, the form control remained in the hasFocus state once you interacted with it until you refreshed the whole page. This caused the error message to always be hidden once you interacted with the field.

Instructions for Reviewers

List of changes in this PR:

  • When the input field loses focus and the vocabulary modal isn't open, the regular onBlur event is now triggered which causes the error message to be displayed
  • When the input field loses focus and the vocabulary modal is open, the onBlur event will not be triggered, otherwise the value won't be properly set

Guidance for how to test this PR: see #4501

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

… user interaction with the field

This was because the blur event was never triggered, so the field still thinks that the field is being focused
@alexandrevryghem alexandrevryghem added this to the 10.0 milestone Jun 23, 2025
@alexandrevryghem alexandrevryghem self-assigned this Jun 23, 2025
@alexandrevryghem alexandrevryghem added component: submission component: controlled vocabulary related to controlled vocabulary or value-pairs dropdowns port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Jun 23, 2025
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Jun 23, 2025
@github-actions
Copy link

github-actions bot commented Jul 8, 2025

Hi @alexandrevryghem,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Copy link

@pzlakowski pzlakowski left a comment

Choose a reason for hiding this comment

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

Checklist:

  • Merge with the newest main
  • Lint test
  • Test behavior
  • Review code

Subjects to do:

  • Merge to current main and resolve merge conflicts
  • Check my comments regarding code changes and find whenever you agree with them

I have checked the PR and it work as intended. I have resoled conflicts myself and tested with current main.

Old behaviour:

Image

New behaviour:

Image

}
this.inputValue = null;
onBlur(event: Event, hierarchical: boolean = false): void {
if (hierarchical) {

Choose a reason for hiding this comment

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

In my opinion it would be better to rewrite conditional in this style. We remove one level of nested conditionals and we separate precondition which does different responsibility with early return.

if (hierarchical) {
    if (!this.vocabularyTreeOpen) {
        super.onBlur(event);
    }
    return; 
}

@tdonohue tdonohue moved this from 🙋 Needs Reviewers Assigned to 👀 Under Review in DSpace 10.0 Release Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug component: controlled vocabulary related to controlled vocabulary or value-pairs dropdowns component: submission merge conflict port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release

Projects

Status: 👀 Under Review

Development

Successfully merging this pull request may close these issues.

Error message from controlled vocabulary fields remains hidden after user interaction

2 participants