No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

focusing-tests.js 908B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module('Selection containers - Managing focus');
  2. var SingleSelection = require('select2/selection/single');
  3. var $ = require('jquery');
  4. var Options = require('select2/options');
  5. var options = new Options({});
  6. test('close sets the focus to the selection', function (assert) {
  7. var $container = $('#qunit-fixture .event-container');
  8. var container = new MockContainer();
  9. var selection = new SingleSelection(
  10. $('#qunit-fixture .single'),
  11. options
  12. );
  13. var $selection = selection.render();
  14. selection.bind(container, $container);
  15. selection.update([{
  16. id: 'test',
  17. text: 'test'
  18. }]);
  19. $container.append($selection);
  20. assert.notEqual(
  21. document.activeElement,
  22. $selection[0],
  23. 'The selection had focus originally'
  24. );
  25. container.trigger('close');
  26. assert.equal(
  27. document.activeElement,
  28. $selection[0],
  29. 'After close, focus must be set to selection'
  30. );
  31. });