Skip to content

Commit

Permalink
Merge pull request #3860 from markusguenther/bugfix-3859
Browse files Browse the repository at this point in the history
BUGFIX: Trim leading and tailing whitespaces
  • Loading branch information
Sebobo authored Oct 10, 2024
2 parents 9754d55 + 500f950 commit f0ac8f1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/neos-ui-editors/src/Library/LinkInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ export default class LinkInput extends PureComponent {
}

handleSearchTermChange = searchTerm => {
// trim leading whitespace as it can cause issues
// with the further processing
if (typeof searchTerm === 'string') {
searchTerm = searchTerm.trimStart();
}

this.setState({searchTerm});

if (isUriOrInternalLink(searchTerm)) {
Expand Down Expand Up @@ -269,9 +275,16 @@ export default class LinkInput extends PureComponent {
}

handleManualSetLink = () => {
this.props.onLinkChange(this.state.searchTerm);
let {searchTerm} = this.state;
// trim tailing whitespace as it can cause issues
if (typeof searchTerm === 'string') {
searchTerm = searchTerm.trim();
this.setState({searchTerm});
}

this.props.onLinkChange(searchTerm);
this.setState({
isEditMode: !this.state.searchTerm
isEditMode: !searchTerm
});
}

Expand Down

0 comments on commit f0ac8f1

Please sign in to comment.