File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -683,7 +683,20 @@ public function setValue($xpath, $value)
683683 }
684684
685685 $ element ->postValue (array ('value ' => array ($ value )));
686- $ this ->trigger ($ xpath , 'change ' );
686+ // Remove the focus from the element if the field still has focus in
687+ // order to trigger the change event. By doing this instead of simply
688+ // triggering the change event for the given xpath we ensure that the
689+ // change event will not be triggered twice for the same element if it
690+ // has lost focus in the meanwhile. If the element has lost focus
691+ // already then there is nothing to do as this will already have caused
692+ // the triggering of the change event for that element.
693+ $ script = <<<JS
694+ var node = {{ELEMENT}};
695+ if (document.activeElement === node) {
696+ document.activeElement.blur();
697+ }
698+ JS ;
699+ $ this ->executeJsOnElement ($ element , $ script );
687700 }
688701
689702 /**
You can’t perform that action at this time.
0 commit comments