Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nav Submenu block Link UI text control #46243

Merged
merged 5 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
* @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
* @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
* @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
* @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
* @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
*/
Expand Down
9 changes: 7 additions & 2 deletions packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import {
useRef,
createInterpolateElement,
} from '@wordpress/element';
import { placeCaretAtHorizontalEdge } from '@wordpress/dom';
import {
placeCaretAtHorizontalEdge,
__unstableStripHTML as stripHTML,
} from '@wordpress/dom';
import { link as linkIcon, removeSubmenu } from '@wordpress/icons';
import {
useResourcePermissions,
Expand Down Expand Up @@ -284,6 +287,7 @@ export default function NavigationSubmenuEdit( {
const { label, type, opensInNewTab, url, description, rel, title, kind } =
attributes;
const link = {
title: label && stripHTML( label ),
url,
opensInNewTab,
};
Expand Down Expand Up @@ -665,7 +669,8 @@ export default function NavigationSubmenuEdit( {
<LinkControl
className="wp-block-navigation-link__inline-link-input"
value={ link }
showInitialSuggestions={ true }
hasTextControl
showInitialSuggestions
withCreateSuggestion={ userCanCreate }
createSuggestion={ handleCreate }
createSuggestionButtonText={ ( searchTerm ) => {
Expand Down