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): tools are active only when all blocks use the tool #6524

Merged
merged 39 commits into from
May 2, 2024
Merged

Conversation

jordanl17
Copy link
Member

@jordanl17 jordanl17 commented Apr 30, 2024

Description

EDX-801

What to review

Different approaches are needed for each of marks, annotations and lists
The high level approach is that instead of a condition on some of the selected blocks being bold, or a link, or bullet list, now every selected block must be.

The most cumbersome implementation is for annotations (links). This requires a new isAnnotationActive method in packages/@sanity/portable-text-editor/src/editor/plugins/createWithEditableAPI.ts which must expand every selected block to determine the type of mark definitions in the selection, before then applying the every logic to all spans in the selection

Testing

Notes for release

fixes issues in the PTE where tools would show as being active for a selection when only part of the selection used the tool.
Now tools will show as active only when all highlighted selections use the tool

jordanl17 and others added 23 commits April 23, 2024 16:29
* fix(core): set scroll boundary to nearest

* fix(core): add smooth scroll behavior

* fix(sanity): remove smooth behavior

---------

Co-authored-by: RitaDias <anarita151@gmail.com>
…ument in PTE (#6440)

* fix(portable-text-editor): issue shown in tests re stega. use duplicate code

* test(playwright-ct): add test

* chore(sanity): remove prettier linting

* test(sanity): fix missing snapshot

* test(sanity): update test after realising the test would pass always if comparing object number

* chore: test unicode removal

* chore: test unicode removal

* chore(@sanity): remove old solution

* fix(@sanity/block-tools): unicode issue. remove vercel/stega and move to block-tools

* test(@sanity/block-tools): for unicode

* fix(@sanity/block-tools): utf8 characters weren't beign filtered. using the vercel/stega

* chore: update lock file

* (chore): update pnpm lock
Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>
…ument in PTE (#6440)

* fix(portable-text-editor): issue shown in tests re stega. use duplicate code

* test(playwright-ct): add test

* chore(sanity): remove prettier linting

* test(sanity): fix missing snapshot

* test(sanity): update test after realising the test would pass always if comparing object number

* chore: test unicode removal

* chore: test unicode removal

* chore(@sanity): remove old solution

* fix(@sanity/block-tools): unicode issue. remove vercel/stega and move to block-tools

* test(@sanity/block-tools): for unicode

* fix(@sanity/block-tools): utf8 characters weren't beign filtered. using the vercel/stega

* chore: update lock file

* (chore): update pnpm lock
Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ument in PTE (#6440)

* fix(portable-text-editor): issue shown in tests re stega. use duplicate code

* test(playwright-ct): add test

* chore(sanity): remove prettier linting

* test(sanity): fix missing snapshot

* test(sanity): update test after realising the test would pass always if comparing object number

* chore: test unicode removal

* chore: test unicode removal

* chore(@sanity): remove old solution

* fix(@sanity/block-tools): unicode issue. remove vercel/stega and move to block-tools

* test(@sanity/block-tools): for unicode

* fix(@sanity/block-tools): utf8 characters weren't beign filtered. using the vercel/stega

* chore: update lock file

* (chore): update pnpm lock
Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Copy link

vercel bot commented Apr 30, 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 2, 2024 2:24pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2024 2:24pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2024 2:24pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 2, 2024 2:24pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 30, 2024

Component Testing Report Updated May 2, 2024 2:28 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 25s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 20s 6 3 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 34s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 5s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 6s 18 0 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) 22s 9 0 0

if (selectedBlocks.length > 0) {
return true
return selectedBlocks.every(
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to return every here or do we just care that there is > 0 blocks that meet this condition?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do care that every block has the list style. For example if the selection was on the following:

First block

  • List second block

Third block

we'd have 3 selectedBlocks, but only 1 would have bullet list style, so we'd want to return false

Copy link
Contributor

@jtpetty jtpetty left a comment

Choose a reason for hiding this comment

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

👍 - thanks for adding more tests!

@jordanl17 jordanl17 added this pull request to the merge queue May 2, 2024
Merged via the queue into next with commit 169e5fd May 2, 2024
40 checks passed
@jordanl17 jordanl17 deleted the EDX-801-2 branch May 2, 2024 15:58
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

6 participants