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: protect against falsy selectedGroup #7593

Merged
merged 1 commit into from
Oct 4, 2024
Merged

fix: protect against falsy selectedGroup #7593

merged 1 commit into from
Oct 4, 2024

Conversation

ricokahler
Copy link
Contributor

Description

This fixes a bug that caused the document editor to crash in certain cases where there is no selected group. This occurs when the default field group is not found. Allow this value to be undefined and checking for it fixes the issue.

What to review

Does this correct protect against all cases where the selectedGroup is undefined? Are all the types updated correctly?

Testing

This was tested manually in the admin studio. I built sanity package, packed it, and install it in the admin studio and the issue was resolved.

Notes for release

Fixes a bug that caused the document editor to crash when the default field group is not found.

@ricokahler ricokahler requested a review from a team as a code owner October 4, 2024 19:34
@ricokahler ricokahler requested review from binoy14 and removed request for a team October 4, 2024 19:34
Copy link

vercel bot commented Oct 4, 2024

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

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 7:37pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 7:37pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 7:37pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 7:37pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 7:37pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Oct 4, 2024 7:37pm

Copy link
Contributor

github-actions bot commented Oct 4, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Oct 4, 2024

Component Testing Report Updated Oct 4, 2024 7:40 PM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 47s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 30s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 37s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 37s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 15s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 8s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 35s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

@ricokahler ricokahler requested review from ryanbonial and removed request for binoy14 October 4, 2024 19:50
Copy link
Contributor

github-actions bot commented Oct 4, 2024

⚡️ Editor Performance Report

Updated Fri, 04 Oct 2024 19:55:06 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 17.9 efps (56ms) 17.7 efps (57ms) +1ms (+0.9%)
article (body) 58.0 efps (17ms) 59.3 efps (17ms) -0ms (-2.3%)
article (string inside object) 19.6 efps (51ms) 19.6 efps (51ms) +0ms (-/-%)
article (string inside array) 14.9 efps (67ms) 15.2 efps (66ms) -1ms (-1.5%)
recipe (name) 31.3 efps (32ms) 30.3 efps (33ms) +1ms (+3.1%)
recipe (description) 34.5 efps (29ms) 34.5 efps (29ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (7ms) 99.9+ efps (7ms) +0ms (-/-%)
synthetic (title) 14.5 efps (69ms) 14.9 efps (67ms) -2ms (-2.9%)
synthetic (string inside object) 15.6 efps (64ms) 15.2 efps (66ms) +2ms (+3.1%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 56ms 60ms 72ms 260ms 1262ms 15.0s
article (body) 17ms 20ms 28ms 170ms 191ms 5.7s
article (string inside object) 51ms 56ms 62ms 195ms 920ms 8.6s
article (string inside array) 67ms 71ms 78ms 266ms 1702ms 10.0s
recipe (name) 32ms 34ms 37ms 88ms 37ms 10.0s
recipe (description) 29ms 31ms 33ms 52ms 23ms 6.1s
recipe (instructions) 7ms 8ms 9ms 22ms 0ms 3.2s
synthetic (title) 69ms 75ms 81ms 241ms 2280ms 17.8s
synthetic (string inside object) 64ms 70ms 73ms 257ms 1967ms 10.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 57ms 61ms 83ms 181ms 1186ms 14.4s
article (body) 17ms 19ms 23ms 145ms 195ms 5.4s
article (string inside object) 51ms 54ms 59ms 90ms 845ms 8.8s
article (string inside array) 66ms 71ms 75ms 273ms 1756ms 9.8s
recipe (name) 33ms 36ms 38ms 68ms 58ms 9.8s
recipe (description) 29ms 32ms 35ms 56ms 39ms 6.2s
recipe (instructions) 7ms 9ms 10ms 45ms 0ms 3.4s
synthetic (title) 67ms 70ms 77ms 164ms 2071ms 18.3s
synthetic (string inside object) 66ms 71ms 87ms 399ms 2323ms 10.5s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

Copy link
Member

@ryanbonial ryanbonial left a comment

Choose a reason for hiding this comment

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

It would be nice to have a test for this case, but the change looks good 👍

@ricokahler ricokahler added this pull request to the merge queue Oct 4, 2024
Merged via the queue into next with commit a89c1aa Oct 4, 2024
63 checks passed
@ricokahler ricokahler deleted the sdx-1651 branch October 4, 2024 20:03
ricokahler added a commit that referenced this pull request Oct 4, 2024
### Description

This fixes a bug that caused the document editor to crash in certain
cases where there is no selected group. This occurs when the default
field group is not found. Allow this value to be `undefined` and
checking for it fixes the issue.

### What to review

Does this correct protect against all cases where the selectedGroup is
undefined? Are all the types updated correctly?

### Testing

This was tested manually in the admin studio. I built sanity package,
packed it, and install it in the admin studio and the issue was
resolved.

### Notes for release

Fixes a bug that caused the document editor to crash when the default
field group is not found.
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.

2 participants