@wordpress/views 1.21.1-next.v.202608281122.0 → 1.21.2-next.v.202609031004.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.21.1-next.0 (2026-09-03)
6
+
7
+ ### Bug Fixes
8
+
9
+ - `useViewConfig`: request the full configuration under the same cache key as `getViewConfig( kind, name )`, so a route loader that preloads it no longer triggers a second request. ([#82141](https://github.com/WordPress/gutenberg/pull/82141))
10
+
5
11
  ## 1.21.0 (2026-08-26)
6
12
 
7
13
  ### Internal
@@ -35,9 +35,13 @@ function useViewConfig({
35
35
  const fieldsKey = fieldList ? [...fieldList].sort().join(",") : void 0;
36
36
  return (0, import_data.useSelect)(
37
37
  (select) => {
38
- return (0, import_lock_unlock.unlock)(select(import_core_data.store)).getViewConfig(kind, name, {
39
- fields: fieldsKey
40
- });
38
+ return (0, import_lock_unlock.unlock)(select(import_core_data.store)).getViewConfig(
39
+ kind,
40
+ name,
41
+ fieldsKey ? {
42
+ fields: fieldsKey
43
+ } : void 0
44
+ );
41
45
  },
42
46
  [kind, name, fieldsKey]
43
47
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/use-view-config.ts"],
4
- "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList\n\t\t? [ ...fieldList ].sort().join( ',' )\n\t\t: undefined;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( coreStore ) ).getViewConfig( kind, name, {\n\t\t\t\tfields: fieldsKey,\n\t\t\t} );\n\t\t},\n\t\t[ kind, name, fieldsKey ]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,uBAAmC;AAEnC,yBAAuB;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,YACf,CAAE,GAAG,SAAU,EAAE,KAAK,EAAE,KAAM,GAAI,IAClC;AACH,aAAO;AAAA,IACN,CAAE,WAAY;AACb,iBAAO,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE,cAAe,MAAM,MAAM;AAAA,QAC/D,QAAQ;AAAA,MACT,CAAE;AAAA,IACH;AAAA,IACA,CAAE,MAAM,MAAM,SAAU;AAAA,EACzB;AACD;",
4
+ "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList\n\t\t? [ ...fieldList ].sort().join( ',' )\n\t\t: undefined;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( coreStore ) ).getViewConfig(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\tfieldsKey\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tfields: fieldsKey,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t);\n\t\t},\n\t\t[ kind, name, fieldsKey ]\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,uBAAmC;AAEnC,yBAAuB;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,YACf,CAAE,GAAG,SAAU,EAAE,KAAK,EAAE,KAAM,GAAI,IAClC;AACH,aAAO;AAAA,IACN,CAAE,WAAY;AACb,iBAAO,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA,YACG;AAAA,UACA,QAAQ;AAAA,QACR,IACA;AAAA,MACJ;AAAA,IACD;AAAA,IACA,CAAE,MAAM,MAAM,SAAU;AAAA,EACzB;AACD;",
6
6
  "names": ["coreStore"]
7
7
  }
@@ -11,9 +11,13 @@ function useViewConfig({
11
11
  const fieldsKey = fieldList ? [...fieldList].sort().join(",") : void 0;
12
12
  return useSelect(
13
13
  (select) => {
14
- return unlock(select(coreStore)).getViewConfig(kind, name, {
15
- fields: fieldsKey
16
- });
14
+ return unlock(select(coreStore)).getViewConfig(
15
+ kind,
16
+ name,
17
+ fieldsKey ? {
18
+ fields: fieldsKey
19
+ } : void 0
20
+ );
17
21
  },
18
22
  [kind, name, fieldsKey]
19
23
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/use-view-config.ts"],
4
- "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList\n\t\t? [ ...fieldList ].sort().join( ',' )\n\t\t: undefined;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( coreStore ) ).getViewConfig( kind, name, {\n\t\t\t\tfields: fieldsKey,\n\t\t\t} );\n\t\t},\n\t\t[ kind, name, fieldsKey ]\n\t);\n}\n"],
5
- "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAEnC,SAAS,cAAc;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,YACf,CAAE,GAAG,SAAU,EAAE,KAAK,EAAE,KAAM,GAAI,IAClC;AACH,SAAO;AAAA,IACN,CAAE,WAAY;AACb,aAAO,OAAQ,OAAQ,SAAU,CAAE,EAAE,cAAe,MAAM,MAAM;AAAA,QAC/D,QAAQ;AAAA,MACT,CAAE;AAAA,IACH;AAAA,IACA,CAAE,MAAM,MAAM,SAAU;AAAA,EACzB;AACD;",
4
+ "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList\n\t\t? [ ...fieldList ].sort().join( ',' )\n\t\t: undefined;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( coreStore ) ).getViewConfig(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\tfieldsKey\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tfields: fieldsKey,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t);\n\t\t},\n\t\t[ kind, name, fieldsKey ]\n\t);\n}\n"],
5
+ "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAEnC,SAAS,cAAc;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,YACf,CAAE,GAAG,SAAU,EAAE,KAAK,EAAE,KAAM,GAAI,IAClC;AACH,SAAO;AAAA,IACN,CAAE,WAAY;AACb,aAAO,OAAQ,OAAQ,SAAU,CAAE,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA,YACG;AAAA,UACA,QAAQ;AAAA,QACR,IACA;AAAA,MACJ;AAAA,IACD;AAAA,IACA,CAAE,MAAM,MAAM,SAAU;AAAA,EACzB;AACD;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-view-config.d.ts","sourceRoot":"","sources":["../src/use-view-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAE,EAC9B,IAAI,EACJ,IAAI,EACJ,MAAM,GACN,EAAE;IACF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B,GAAI;IACJ,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B,eAAe,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC9C,SAAS,EAAE,KAAK,CAAE,GAAG,CAAE,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACvB,CAeA"}
1
+ {"version":3,"file":"use-view-config.d.ts","sourceRoot":"","sources":["../src/use-view-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAE,EAC9B,IAAI,EACJ,IAAI,EACJ,MAAM,GACN,EAAE;IACF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B,GAAI;IACJ,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B,eAAe,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC9C,SAAS,EAAE,KAAK,CAAE,GAAG,CAAE,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACvB,CAqBA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/views",
3
- "version": "1.21.1-next.v.202608281122.0",
3
+ "version": "1.21.2-next.v.202609031004.0",
4
4
  "description": "View persistence and management for WordPress DataViews.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -41,22 +41,23 @@
41
41
  },
42
42
  "types": "build-types",
43
43
  "dependencies": {
44
- "@wordpress/core-data": "^7.54.2-next.v.202608281122.0",
45
- "@wordpress/data": "^10.54.2-next.v.202608281122.0",
46
- "@wordpress/dataviews": "^18.1.2-next.v.202608281122.0",
47
- "@wordpress/element": "^8.6.2-next.v.202608281122.0",
48
- "@wordpress/preferences": "^4.54.2-next.v.202608281122.0",
49
- "@wordpress/private-apis": "^1.54.1-next.v.202608281122.0",
44
+ "@wordpress/core-data": "^8.0.1-next.v.202609031004.0",
45
+ "@wordpress/data": "^10.54.2-next.v.202609031004.0",
46
+ "@wordpress/dataviews": "^19.0.1-next.v.202609031004.0",
47
+ "@wordpress/element": "^8.6.2-next.v.202609031004.0",
48
+ "@wordpress/preferences": "^4.54.2-next.v.202609031004.0",
49
+ "@wordpress/private-apis": "^1.54.2-next.v.202609031004.0",
50
50
  "dequal": "^2.0.3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@testing-library/react": "^16.3.2",
54
54
  "@types/jest": "^30.0.0",
55
55
  "react": "^18.3.1",
56
- "react-dom": "^18.3.1"
56
+ "react-dom": "^18.3.1",
57
+ "vitest": "^4.1.10"
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public"
60
61
  },
61
- "gitHead": "de479d415171765f7b573c81aeec5334ff506a12"
62
+ "gitHead": "7275d6c6d93b542fca3cd98cdb9c7344ddd11e19"
62
63
  }
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import type { View } from '@wordpress/dataviews';
2
3
  import { getUserModifications, resolveView } from '../resolve-view';
3
4
 
@@ -40,9 +40,15 @@ export function useViewConfig( {
40
40
  : undefined;
41
41
  return useSelect(
42
42
  ( select ) => {
43
- return unlock( select( coreStore ) ).getViewConfig( kind, name, {
44
- fields: fieldsKey,
45
- } );
43
+ return unlock( select( coreStore ) ).getViewConfig(
44
+ kind,
45
+ name,
46
+ fieldsKey
47
+ ? {
48
+ fields: fieldsKey,
49
+ }
50
+ : undefined
51
+ );
46
52
  },
47
53
  [ kind, name, fieldsKey ]
48
54
  );