Skip to content

Commit

Permalink
🐛 Fixed unnecessary "unsaved changes" modal when using HR cards
Browse files Browse the repository at this point in the history
no issue

- the `hr` mobiledoc card does not specify an `absoluteToRelative` or `relativeToAbsolute` transformer function so falls back to the default transformer
- the default transformer function's arguments were not correct which meant that the UrlUtils object was replacing the card's typical empty-object payload
- the card's payload changing when saving mobiledoc was triggering the editor's unsaved changes warning because the API response no longer matched what was in the editor
  • Loading branch information
kevinansfield committed Jan 22, 2020
1 parent 6e02433 commit 8b787ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/server/lib/mobiledoc/create-card.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let urlUtils;

module.exports = function createCard(card) {
const defaultTransformer = function (payload) {
const defaultTransformer = function (urlUtils, payload) {
return payload;
};

Expand Down
12 changes: 12 additions & 0 deletions core/test/unit/lib/mobiledoc/cards/hr_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ describe('HR card', function () {

serializer.serialize(card.render(opts)).should.match('<hr>');
});

it('transforms urls absolute to relative', function () {
let payload = {};
const transformed = card.absoluteToRelative(payload, {});
transformed.should.deepEqual({});
});

it('transforms urls relative to absolute', function () {
let payload = {};
const transformed = card.relativeToAbsolute(payload, {});
transformed.should.deepEqual({});
});
});

0 comments on commit 8b787ac

Please sign in to comment.