class FocusFirstCommand
Same name in other branches
- 9 core/lib/Drupal/Core/Ajax/FocusFirstCommand.php \Drupal\Core\Ajax\FocusFirstCommand
- 11.x core/lib/Drupal/Core/Ajax/FocusFirstCommand.php \Drupal\Core\Ajax\FocusFirstCommand
AJAX command for focusing an element.
This command is provided a selector then does the following:
- The first element matching the provided selector will become the container where the search for tabbable elements is conducted.
- If one or more tabbable elements are found within the container, the first of those will receive focus.
- If no tabbable elements are found within the container, but the container itself is focusable, then the container will receive focus.
- If the container is not focusable and contains no tabbable elements, the triggering element will remain focused.
Hierarchy
- class \Drupal\Core\Ajax\FocusFirstCommand implements \Drupal\Core\Ajax\CommandInterface
Expanded class hierarchy of FocusFirstCommand
See also
Drupal.AjaxCommands.focusFirst
Related topics
4 files declare their use of FocusFirstCommand
- AddFormBase.php in core/
modules/ media_library/ src/ Form/ AddFormBase.php - AjaxTestFocusFirstForm.php in core/
modules/ system/ tests/ modules/ ajax_test/ src/ Form/ AjaxTestFocusFirstForm.php - ListItemBase.php in core/
modules/ options/ src/ Plugin/ Field/ FieldType/ ListItemBase.php - WidgetBase.php in core/
lib/ Drupal/ Core/ Field/ WidgetBase.php
File
-
core/
lib/ Drupal/ Core/ Ajax/ FocusFirstCommand.php, line 22
Namespace
Drupal\Core\AjaxView source
class FocusFirstCommand implements CommandInterface {
/**
* The selector of the container with tabbable elements.
*
* @var string
*/
protected $selector;
/**
* Constructs an FocusFirstCommand object.
*
* @param string $selector
* The selector of the container with tabbable elements.
*/
public function __construct($selector) {
$this->selector = $selector;
}
/**
* {@inheritdoc}
*/
public function render() {
return [
'command' => 'focusFirst',
'selector' => $this->selector,
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
FocusFirstCommand::$selector | protected | property | The selector of the container with tabbable elements. | |
FocusFirstCommand::render | public | function | Overrides CommandInterface::render | |
FocusFirstCommand::__construct | public | function | Constructs an FocusFirstCommand object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.