Skip to content

Commit

Permalink
fix(form/inputs): include text blocks in PT-members when theya are fo…
Browse files Browse the repository at this point in the history
…cused (#5502)

Regular text blocks must be included in the PT-member array when they are focused too, or they can't be focused by pointing the focusPath to them.
  • Loading branch information
skogsmaskin authored Jan 15, 2024
1 parent 2fe7f09 commit f2a228f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ const reconcilePortableTextMembers = ({
if (isObjectBlock) {
result.push({kind: 'objectBlock', member, node: member.item})
} else {
// Also include regular text blocks with validation, presence or changes.
// Also include regular text blocks with validation, presence, changes or that are focused by the user.
// This is a performance optimization to avoid accounting for blocks that
// doesn't need to be re-rendered (which usually is most of the blocks).
if (
member.item.validation.length > 0 ||
member.item.changed ||
member.item.presence?.length
member.item.presence?.length ||
member.item.focusPath.length > 0
) {
result.push({kind: 'textBlock', member, node: member.item})
}
Expand Down

2 comments on commit f2a228f

@vercel
Copy link

@vercel vercel bot commented on f2a228f Jan 15, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio-git-next.sanity.build
performance-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on f2a228f Jan 15, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

Please sign in to comment.