diff --git a/app/assets/javascripts/enhancedTextbox.js b/app/assets/javascripts/enhancedTextbox.js index 8adb210f8..a4965857a 100644 --- a/app/assets/javascripts/enhancedTextbox.js +++ b/app/assets/javascripts/enhancedTextbox.js @@ -27,6 +27,8 @@ `)) .on("input", this.update); + $(window).on("resize", this.resize); + visibleTextbox = this.$textbox.clone().appendTo("body").css({ position: 'absolute', visibility: 'hidden', @@ -47,7 +49,7 @@ this.resize = () => { - this.$background.width(this.$textbox.outerWidth()); + this.$background.width(this.$textbox.width()); this.$textbox.height( Math.max( diff --git a/tests/javascripts/enhancedTextbox.test.js b/tests/javascripts/enhancedTextbox.test.js index 7f6db2155..9cd031900 100644 --- a/tests/javascripts/enhancedTextbox.test.js +++ b/tests/javascripts/enhancedTextbox.test.js @@ -107,8 +107,7 @@ describe('Enhanced textbox', () => { backgroundEl = textarea.nextElementSibling; - // element has box-sizing: border-box so width includes padding and border - expect(backgroundEl.style.width).toEqual('582px'); + expect(backgroundEl.style.width).toEqual('576px'); expect(backgroundEl.style.borderWidth).toEqual('1px'); }); @@ -117,8 +116,7 @@ describe('Enhanced textbox', () => { backgroundEl = input.nextElementSibling; - // element has box-sizing: border-box so width includes padding and border - expect(backgroundEl.style.width).toEqual('582px'); + expect(backgroundEl.style.width).toEqual('576px'); expect(backgroundEl.style.borderWidth).toEqual('1px'); }); @@ -147,7 +145,7 @@ describe('Enhanced textbox', () => { test("If the textbox is an