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

Refactor: update Honorific block to only accept labels and add field validation #7564

Merged
merged 7 commits into from
Oct 16, 2024

Conversation

jonwaldstein
Copy link
Contributor

@jonwaldstein jonwaldstein commented Oct 4, 2024

Resolves GIVE-1292

Description

I noticed the honorific block was offering to "show values", except it didn't actually do anything with the values. Since honorifics are both a value and label, also used in global settings I decided to remove the option for showing values.

Furthermore, extra field validation was added to only accept the available select options.

Affects

The honorific block & field

Visuals

The problem discovery

https://www.loom.com/share/1ae99a62f60a4e96b47d00f394de0681?sid=79a84b4c-427e-4b0d-9f99-44d684b6f0bb

The fix

https://www.loom.com/share/0bc214e053b64e458a4bea57a5454d0f?sid=28e23e37-1510-4f56-9edf-248cb884f2bf

Testing Instructions

  • Interact with the honorific block & field
  • Try submitting a value that is not in the listed options

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@jonwaldstein jonwaldstein marked this pull request as ready for review October 4, 2024 19:55
@JoshuaHungDinh
Copy link
Contributor

JoshuaHungDinh commented Oct 4, 2024

@jonwaldstein I noticed the build settings are not persisting properly after you refresh the page. It looks like the options state is being updated from a useEffect in givewp/src/FormBuilder/resources/js/form-builder/src/blocks/fields/donor-name/Edit.tsx.

I confirmed this is currently an issue in develop as well but could be fixed with a conditional if you would like to include that in this PR since its relative to this setting. Otherwise I can open a new one.

Heres a short video of the bug: .

Screen.Recording.2024-10-04.at.2.55.27.PM.mov

$group->getNodeByName('honorific')
->label('Title')
->options(...array_values($block->getAttribute('honorifics')));
$options = array_values((array)$block->getAttribute('honorifics'));
Copy link
Contributor

@JoshuaHungDinh JoshuaHungDinh Oct 4, 2024

Choose a reason for hiding this comment

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

Should we check for empty strings when passing the options? I found you can add an empty option and it will display. Not a big deal i'm not sure why someone would add a label and not fill it out but it's just something I noticed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch! resolved f3eed61

@jonwaldstein
Copy link
Contributor Author

@JoshuaHungDinh this is ready for re-review. Also fixed those options not persisting 74de009

I think there are further improvements we can make here but this should be good for now.

Copy link
Contributor

@JoshuaHungDinh JoshuaHungDinh left a comment

Choose a reason for hiding this comment

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

Awesome, this should be good to go!

Copy link
Contributor

@JoshuaHungDinh JoshuaHungDinh left a comment

Choose a reason for hiding this comment

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

Awesome, this should be good to go!

Copy link
Member

@rickalday rickalday left a comment

Choose a reason for hiding this comment

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

Pass manual QA tests.

@jonwaldstein jonwaldstein merged commit b3d615c into develop Oct 16, 2024
20 checks passed
@jonwaldstein jonwaldstein deleted the refactor/v3-honorific-field branch October 16, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants