From a264160791548d529408f04d90e0d1e71b10b93c Mon Sep 17 00:00:00 2001 From: Tom Usborne Date: Fri, 6 Dec 2024 10:22:26 -0500 Subject: [PATCH] Check tag type --- .../components/DynamicTagSelect.jsx | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/dynamic-tags/components/DynamicTagSelect.jsx b/src/dynamic-tags/components/DynamicTagSelect.jsx index 9a3a606e9..1eea92c92 100644 --- a/src/dynamic-tags/components/DynamicTagSelect.jsx +++ b/src/dynamic-tags/components/DynamicTagSelect.jsx @@ -418,7 +418,6 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost setDynamicSource( 'user' ); setUserSource( id ); } else if ( 'media' === type ) { - setDynamicSource( 'media' ); setMediaSource( id ); } else { setDynamicSource( 'post' ); @@ -517,8 +516,6 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost setDynamicSource( 'term' ); } else if ( userSource && 'user' === dynamicTagType && 'user' !== dynamicSource ) { setDynamicSource( 'user' ); - } else if ( mediaSource && 'media' === dynamicTagType && 'media' !== dynamicSource ) { - setDynamicSource( 'media' ); } else if ( ! dynamicSource ) { setDynamicSource( 'current' ); } @@ -533,7 +530,7 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost options.push( `id:${ termSource }` ); } else if ( userSource && 'user' === dynamicSource ) { options.push( `id:${ userSource }` ); - } else if ( mediaSource && 'media' === dynamicSource ) { + } else if ( mediaSource && 'media' === dynamicTagType ) { options.push( `id:${ mediaSource }` ); } @@ -731,25 +728,6 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost ) } - { 'media' === dynamicSource && ( - <> - setMediaSource( selected?.value ?? '' ) } - onClear={ () => setMediaSource( '' ) } - onAdd={ ( { inputValue } ) => setMediaSource( inputValue ) } - onEnter={ ( inputValue ) => { - setMediaSource( inputValue ); - } } - currentPostId={ currentPostId } - includeCurrent={ false } - postStatus={ [ 'inherit' ] } - postType={ [ 'attachment' ] } - /> - - ) } - { 'user' === dynamicSource && ( <> ) } + { 'media' === dynamicTagType && ( + <> + setMediaSource( selected?.value ?? '' ) } + onClear={ () => setMediaSource( '' ) } + onAdd={ ( { inputValue } ) => setMediaSource( inputValue ) } + onEnter={ ( inputValue ) => { + setMediaSource( inputValue ); + } } + currentPostId={ currentPostId } + includeCurrent={ false } + postStatus={ [ 'inherit' ] } + postType={ [ 'attachment' ] } + /> + + ) } + { tagSupportsMeta && (