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(pte): update to allow block styles to be hidden #6379

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

Conversation

jtpetty
Copy link
Contributor

@jtpetty jtpetty commented Apr 15, 2024

Description

Fixes EDX-668

By default, we explicitly add in an entry for a Normal block style. This PR adds an option to hide block styles since there is no way to exclude a Normal style

Before:

styles: [{title: 'H1', value: 'h1'}, {title: 'H2', value: 'h2'}],
image

After:

styles: [{title: 'Normal', value: 'normal', hidden: true}, {title: 'H1', value: 'h1'}, {title: 'H2', value: 'h2'}],
image

What to review

I am not sure if this is the best way to solve this issue. This seemed to be the most natural since we were explicitly adding Normal styles before and I assume that was done intentionally. Removing that would be a breaking change. I also didn't want to add another property noDefaultNormal or something like that. Open to other suggestions.

Testing

Manual testing for now, but will add tests once the approach is validated.

Notes for release

Copy link

vercel bot commented Apr 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview May 22, 2024 1:00pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 1:00pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 1:00pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 22, 2024 1:00pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 15, 2024

Component Testing Report Updated May 22, 2024 12:59 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 34s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 16s 20 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 3s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 20s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 29s 12 0 0

@@ -108,13 +108,17 @@ function ensureNormalStyle(styles: any) {
: [BLOCK_STYLES.normal, ...styles]
}

function filterHiddenStyles(styles: any) {
return styles.filter((style: any) => !style.hidden)
Copy link
Member

Choose a reason for hiding this comment

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

COULD: this would allow for any and all styles to be removed, is that ok? Or if the requirement is only to allow for hiding normal style at this stage might be able to check for this in the filter also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great question! It seemed odd to only allow hidden in the 'normal' style. Yes, I think potentially someone could remove all styles, but in practice, would they and what would that mean?

@jtpetty jtpetty marked this pull request as ready for review April 16, 2024 19:06
@jtpetty jtpetty requested review from a team as code owners April 16, 2024 19:06
@jtpetty jtpetty requested review from RitaDias and binoy14 and removed request for a team April 16, 2024 19:06
Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

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

This looks like a good approach!
I think that I would like to hear some thoughts from someone on the design side about what they think about the UX of it apart from my thoughts on it :)

We should also add this to documentation so that more people are aware that they can do this 👍

@RitaDias
Copy link
Contributor

@jtpetty Fred brought up something on slack which might be worth having a look at. In instances where you create a new block (with already some text there) then the new text will be on the "normal style" and a new item will be added to the dropdown called "no style". I think this is something we should account for / discuss on what we want to happen then :)

You can see the example and thread here

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.

None yet

3 participants