Fixes #2887 - Entering pending till time for Waiting status is difficult to enter with Firefox

This commit is contained in:
Mantas 2020-08-17 13:03:40 +03:00 committed by Thorsten Eckel
parent b828c7bda0
commit b58225a19a
5 changed files with 58 additions and 1 deletions

View file

@ -111,11 +111,13 @@
} }
this.setDefaultTime(this.defaultTime); this.setDefaultTime(this.defaultTime);
this.blurElement()
}, },
blurElement: function() { blurElement: function() {
this.highlightedUnit = null; this.highlightedUnit = null;
this.updateFromElementVal(); this.updateFromElementVal();
this.$element.get(0).setSelectionRange(0,0)
}, },
clear: function() { clear: function() {
@ -259,7 +261,7 @@
switch (this.getCursorPosition()) { switch (this.getCursorPosition()) {
case 1: case 1:
// highlight minutes but async because the newly typed character is not yet stored in the value (happens after this event) // highlight minutes but async because the newly typed character is not yet stored in the value (happens after this event)
setTimeout($.proxy(this.highlightMinute, this), 0); setTimeout($.proxy(this.highlightMinute, this), 50);
break; break;
} }
} }

View file

@ -0,0 +1,21 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_datetime.js", nonce: true %>
<style type="text/css">
body {
padding-top: 0px;
}
</style>
<%= javascript_tag nonce: true do -%>
<% end -%>
<div id="qunit" class="u-dontfold"></div>
<div>
<form class="form-stacked pull-left">
<div id="forms"></div>
<button type="submit" class="btn btn-primary submit">Submit</button>
</form>
</div>

View file

@ -22,6 +22,7 @@ Zammad::Application.routes.draw do
match '/tests_form_ticket_perform_action', to: 'tests#form_ticket_perform_action', via: :get match '/tests_form_ticket_perform_action', to: 'tests#form_ticket_perform_action', via: :get
match '/tests_form_sla_times', to: 'tests#form_sla_times', via: :get match '/tests_form_sla_times', to: 'tests#form_sla_times', via: :get
match '/tests_form_skip_rendering', to: 'tests#form_skip_rendering', via: :get match '/tests_form_skip_rendering', to: 'tests#form_skip_rendering', via: :get
match '/tests_form_datetime', to: 'tests#form_datetime', via: :get
match '/tests_table', to: 'tests#table', via: :get match '/tests_table', to: 'tests#table', via: :get
match '/tests_table_extended', to: 'tests#table_extended', via: :get match '/tests_table_extended', to: 'tests#table_extended', via: :get
match '/tests_html_utils', to: 'tests#html_utils', via: :get match '/tests_html_utils', to: 'tests#html_utils', via: :get

View file

@ -0,0 +1,29 @@
test("DateTime timepicker focuses hours", function(assert) {
var done = assert.async(1)
var form = $('#forms')
var el = $('<div></div>').attr('id', 'form1')
el.appendTo(form)
new App.ControllerForm({
el: el,
model: {
configure_attributes: [
{ name: 'datetime1', display: 'Datetime1', tag: 'datetime', null: true },
]
},
autofocus: true
});
let timepicker = el.find('[data-item=time]')
timepicker.focus()
setTimeout(function(){ // give it time to apply focus
equal(timepicker[0].selectionStart, 0)
equal(timepicker[0].selectionEnd, 2)
done()
}, 100)
});

View file

@ -121,6 +121,10 @@ RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, we
it 'SLA times' do it 'SLA times' do
q_unit_tests('form_sla_times') q_unit_tests('form_sla_times')
end end
it 'DateTime' do
q_unit_tests('form_datetime')
end
end end
context 'Table' do context 'Table' do