Skip to content

Commit

Permalink
Disable Link field if value is a post
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Aug 25, 2023
1 parent f8a1cfb commit 9128d72
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ function LinkControl( {
createSuggestionButtonText
}
hideLabelFromVision={ ! showTextControl }
isDisabled={ value?.id }
/>
</div>
{ errorMessage && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const LinkControlSearchInput = forwardRef(
withURLSuggestion = true,
createSuggestionButtonText,
hideLabelFromVision = false,
isDisabled = false,
},
ref
) => {
Expand Down Expand Up @@ -156,6 +157,7 @@ const LinkControlSearchInput = forwardRef(
}
} }
ref={ ref }
isDisabled={ isDisabled }
/>
{ children }
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class URLInput extends Component {
__experimentalRenderControl: renderControl,
value = '',
hideLabelFromVision = false,
isDisabled,
} = this.props;

const {
Expand Down Expand Up @@ -476,6 +477,7 @@ class URLInput extends Component {
? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`
: undefined,
ref: this.inputRef,
disabled: isDisabled,
};

if ( renderControl ) {
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/navigation-link/link-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function LinkUI( props ) {
};
}

const { label, url, opensInNewTab, type, kind } = props.link;
const { label, url, opensInNewTab, type, kind, id } = props.link;

let userCanCreate = false;
if ( ! type || type === 'page' ) {
Expand All @@ -174,8 +174,9 @@ export function LinkUI( props ) {
url,
opensInNewTab,
title: label && stripHTML( label ),
id,
} ),
[ label, opensInNewTab, url ]
[ label, opensInNewTab, url, id ]
);

return (
Expand Down

0 comments on commit 9128d72

Please sign in to comment.