Skip to content

Return stable empty values from the editor store selectors - #160

Merged
s3rgiosan merged 2 commits into
10up:developfrom
s3rgiosan:159/stable-empty-selector-results
Nov 19, 2026
Merged

s3rgiosan merged 2 commits into
10up:developfrom
s3rgiosan:159/stable-empty-selector-results

Conversation

@s3rgiosan

Copy link
Copy Markdown
Member

Fixes #159.

Changes

  1. getRelationships returns one shared empty object when the post ID is null or the store has no entry.
  2. getRelatedEntities returns one shared empty array in the same cases.
  3. New store tests check that each selector returns the same reference on repeated calls with no data.
  4. The editor bundles are rebuilt. The dist/ diff also has the output changes from the current package-lock.json.

Testing

  1. npx 10up-toolkit test-unit-jest --env=node assets/js passes (28 tests). The two new tests fail without the fix. npm test stops before it runs tests because jest-environment-jsdom is not installed.
  2. Set SCRIPT_DEBUG to true and open a post with a relationship in the block editor. The console shows no useSelect warnings for relationships or relatedEntities.
  3. The relationship panel loads, and search, add, and remove work as before.

getRelationships and getRelatedEntities return shared empty values when the store has no data, so useSelect gets the same reference on each call. The editor bundles are rebuilt.
rickalee
rickalee previously approved these changes Nov 19, 2026
@s3rgiosan
s3rgiosan enabled auto-merge (squash) November 19, 2026 20:21
…elector-results

# Conflicts:
#	dist/js/block-editor.asset.php
#	dist/js/block-editor.js
#	dist/js/classic-editor.asset.php
#	dist/js/classic-editor.js
@s3rgiosan
s3rgiosan merged commit e2243b4 into 10up:develop Nov 19, 2026
11 checks passed
@s3rgiosan
s3rgiosan deleted the 159/stable-empty-selector-results branch November 19, 2026 20:56
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.

Editor store selectors return a new empty value on each call

3 participants