Jake Vanderwerf
2026-09-14 7935d26cd16a4f8f69a59a44e27a7263b60e54bf
src/_meta/fields/selector-field.js
@@ -12,13 +12,13 @@
   }
   if (subtype === 'taxonomy') {
      // Assumes taxonomy rest_base matches the (unprefixed) taxonomy slug.
      return (search) => addQueryArgs(`/wp/v2/${field.taxonomy}`, { search, per_page: 20 });
      return (search) => addQueryArgs(`/wp/v2/${field.taxonomy}`, { search, per_page: 20, hide_empty: false });
   }
   return (search) => addQueryArgs('/wp/v2/search', { search, type: 'post', subtype: field.post_type, per_page: 20 });
};
const createPayload = (field, subtype, name) =>
   subtype === 'post' ? { title: name, status: 'publish', postType: field.post_type } : { name };
   subtype === 'post' ? { title: name, status: 'publish', postType: field.post_type } : { name: name };
const labelOf = (item, subtype) => (subtype === 'user' ? item.name : item.title?.rendered ?? item.title ?? item.name);
@@ -40,6 +40,7 @@
   // Resolve current IDs to labels on mount / value change
   useEffect(() => {
      onInputChange('');
      let cancelled = false;
      if (!ids.length) {
         setTokens([]);
@@ -65,7 +66,6 @@
   const onInputChange = useCallback((search) => {
      setSearch(search);
      if (!search) { setOptions({}); return;}
      apiFetch({ path: buildPath(search) })
         .then((results) => {
@@ -81,7 +81,7 @@
      if (isSingle) {
         onChange(newIds[newIds.length - 1] ?? 0);
      } else {
         onChange(field.max ? newIds.slice(0, field.max) : newIds);
         onChange((field.max ? newIds.slice(0, field.max) : newIds).join(','));
      }
   };
@@ -90,7 +90,7 @@
      if (pendingCreate && canCreate && !creating) {
         setCreating(true);
         apiFetch({ path: `/wp/v2/${field.taxonomy}`, method: 'POST', data: createPayload(subtype, search) })
         apiFetch({ path: `/wp/v2/${field.taxonomy}`, method: 'POST', data: createPayload(field, subtype, search) })
            .then((item) => {
               const label = labelOf(item, subtype);
               const finalTokens = tokens.filter((t) => t !== createLabel).concat(label);