Fix bug in which we could not insert images or links using the editor #1
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.
Problem
Editing description to insert external link and images is not working on Teespring.
Steps to reproduce
Expected behavior
Actual behavior
Found issue
When we click on buttons "insert link" or "insert image", the following JS error was raised:
Uncaught TypeError: Failed to execute 'focus' on 'HTMLElement': parameter 1 ('options') is not an object.
.This was a known issue, that was fixed in newer versions of the
bootstrap-wysihtml5
gem (see: jhollingworth/bootstrap-wysihtml5#391). Currently, we are using a fork from the0.3.1.24
version, and the latest version of the original gem is0.3.3.8
Solution
As we on Teespring are using a fork of that gem, upgrading the gem is not direct. Also, I tried to upgrade the gem locally (using the original gem instead of the fork), but there were a bunch of errors during upgrade that we'd need to solve.
So, I decided to solve the problem manually on our fork of the gem.
The problem was solved by replacing
element.focus(false)
calls withelement.focus({})
, because thefocus
function expects an object as its argument (see: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus and jhollingworth/bootstrap-wysihtml5#391 (comment)).Additional changes
While testing this, @helenlam requested the following:
'http://'
a placeholder, instead of the actual initial value of the fields.Those changes are also included in this PR, in separate commits.
Link to ticket
https://www.pivotaltracker.com/story/show/162432786