From 1acb7dc24f4b8299c7c1335a090c8ee116fa7c88 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 6 Sep 2012 15:52:31 -0400 Subject: [PATCH] Add a short delay to calculator input focus so it doesn't jump to the bottom of the screen when you open it. --- lms/static/coffee/src/calculator.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lms/static/coffee/src/calculator.coffee b/lms/static/coffee/src/calculator.coffee index 2cf4893d52..788081ebd6 100644 --- a/lms/static/coffee/src/calculator.coffee +++ b/lms/static/coffee/src/calculator.coffee @@ -9,11 +9,14 @@ class @Calculator toggle: (event) -> event.preventDefault() $('div.calc-main').toggleClass 'open' - $('#calculator_wrapper #calculator_input').focus() if $('.calc.closed').length $('.calc').attr 'aria-label', 'Open Calculator' else $('.calc').attr 'aria-label', 'Close Calculator' + # TODO: Investigate why doing this without the timeout causes it to jump + # down to the bottom of the page. I suspect it's because it's putting the + # focus on the text field before it transitions onto the page. + setTimeout (-> $('#calculator_wrapper #calculator_input').focus()), 100 $('.calc').toggleClass 'closed'