Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should fix
prependHTTP
instead.In its definition, it's expected to pass
string
so it should return the original value otherwise. It'd be similar to whataddQueryArgs
does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you prefer the fix to prependHTTP as a separate PR to the UI enhancements that @senadir has suggested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI enhancement can be filed as a separate issue. We should fix the bug in the first place to make it usable :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it with the Class block and it looks like the way it's handled there is, it gets never converted into a link if you leave the input field empty. In the case where you remove the URL and save it, it works as if you would remove the link. We should replicate the same behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the PR to just return the original value in prependHTTP instead. This fixes the bug - not sure if we want to do a proper check for a string value rather than a simple truthy check.
With removing the link if url is not set, this is slightly complicated by the fact that we need to account for existing named anchor tags that will have no url attribute. The Classic block does account for these, and it has a different UI treatment for anchors. Do we want to combine looking at this in a separate PR along with the UI enhancements mentioned above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My feeling is that it's probably best to get this fix in as is, and then look to do other improvements separately. The current fix improves things quite a bit, and leaves only a couple of rough edges (which is way better than a crashing block).
Bearing in mind there's some work (#17846) to revamp the link interface going on separately, it might be best to create a separate issue and seek some design feedback on how to handle this use case. It can then be factored in to the new design.
What do think @gziolo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing has changed. Let's get it in 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed a follow-up: #17972