I'd like to write a Cypress test to verify that pressing ctrl-z (or cmd on a Mac but ignoring that for now) in an <input> text undoes the previously-typed text. For example:
cy.get('input')
.type('abc')
.should('have.value', 'abc')
.type('{ctrl+z}')
.should('have.value', '');
However, the .type('{ctrl+z}') doesn't actually seem to trigger the undo. This surprised me because I was able to trigger a custom keydown EventListener with the same .type('{ctrl+z}').
I know Cypress doesn't support keyboard shortcuts for copying/pasting, and I'm wondering if I'm running up against a limitation here.
I get that it's usually unnecessary to check something like this, which is default browser behavior and should work. But in my case, I want to make sure that my global ctrl-z listener isn't preventing the default undo behavior from firing.
You can do it with cypress-real-events
cy.get("input").focus();
cy.realType("abc")
cy.get("input").should('have.value', 'abc') // passes
cy.realPress(["Control", "z"])
cy.get("input").should('have.value', '') // passes
Install with
npm install cypress-real-events
// or
yarn add cypress-real-events
Add an import to cypress/suport/e2e.js
import "cypress-real-events/support";
Related
I program php in Laravel and don't use the myriad of native php functions hardly ever. So I don't need the huge list of php functions that are irrelevant to me to pop up all the time as auto-complete suggestions.
I want my own snippets (which are really useful and cool) to appear but nothing else.
Tried in user/preferences "auto_complete": false
All that does is stop the box from showing on the screen, but the suggestions are still present and will be triggered. I want to switch them off completely, except my own snippets.
The potential of custom snippets to generate oft. used code is wonderful. Would like to add more.
But need to remove the above unnnecessaries first so it's not constantly triggering nonsense that just has to be deleted, interrupting flow. How?
You can add delay timer for auto complete with:
"auto_complete_delay": number in miliseconds
So it will delay for auto complete trigger. This way you will hardly see it if you give it something like 2-3 minutes.
While using the amazing Python Jedi plugin from GVim, I have started noticing some odd behavior with function completion tips popup (not the autocomplete as far as I can tell).
Firstly, while the function argument helper popup is visible, GVim input becomes laggy, even for builtin functions and standard types. Once the popup is closed, lag disappears. Autocomplete seems to work just fine on all levels, this lag seems to only apply to the function helper.
Secondly, I recently had a case where a popup became frozen in the buffer, even after it should have closed, and actually replaced the contents of the buffer at that location in the file. I finished the function I was working on, and then used :/__init to jump cursor location. My window scrolled down, but apparently the original function popup didn't clear, and become a fixture in my text.
When I saved the file, that line was replaced with the popup contents (obviously threw an Exception when python tried to execute that line). Going back to that location in the file, reactivating that function help popup and then closing it again fixed the frozen popup text.
Are these problems related?
Is this an aggressive configuration setting that I should change. Honestly those popups are a bit too aggressive for my liking sometimes, so how do I disable/hotkey-bind them in the configuration?
I have only experienced this behavior in GVim. Maybe it happens in console vim, but I have not tried to reproduce the situation, so I don't know.
GVim circumstances:
7 tabs open
each tab usually has two vertical windows
each window is usually a separate python module
There's a multitude of issues about this on jedi-vim's issue tracker: https://github.com/davidhalter/jedi-vim/issues/217. The whole lag situation is slowly getting better.
One of the easiest solutions is to just disable call signatures:
g:jedi#show_call_signatures = "0"
As of now (I just merged that), there's another way of displaying call signatures:
The call signatures can be displayed as a pop-up in the buffer (set to
1, the default), which has the advantage of being easier to refer to,
or in Vim's command line aligned with the function call (set to 2),
which can improve the integrity of Vim's undo history.
You could try if you like this better (but you have to update jedi-vim):
g:jedi#show_call_signatures = "2"
I am writing a plugin that uses a dialog box.
I notice that clicking the toolbar button to open the dialog box fires a change event on the editor. Is there anyway to disable this event when opening the dialog box?
The plugin modifies the content using setAttribute(), removeAttribute(), and removeStyles(). Is there anyway to have calls to these methods fire a change event?
After more investigation, I discovered 2 issues (which I think relates to using YUI's App Framework), which might be the cause of the unexpected behaviour.
To reproduce: http://jsfiddle.net/c3tqk/
Problem 1:
1. Select part of the first paragraph (text) and click the Edit Link button.
2. Select part of the second paragraph (link) and click the Edit Link button. Check the console and notice a change event is fired.
Problem 2:
1. Select ex in the first paragraph and click the Bold button.
2. Deselect and select the x in the first paragraph and click the Bold button. Notice that the change event is fired twice.
You can always fire an event manually though it's not usually recommended. Use CKEDITOR.event.fire:
element.setAttribute( 'foo', 'bar' );
editor.fire( 'change' );
A better idea is to use editor#saveSnapshot event, which creates undo snapshots (your change becomes officially undoable, that's pretty cool) and fires editor#change automatically, if needed:
element.setAttribute( 'foo', 'bar' );
editor.fire( 'saveSnapshot' );
You can also interrupt existing events as they get fired and make sure no other listeners are called. Simply use CKEDITOR.event.on listener with low priority.
editor.on( 'change', function( evt ) {
if ( some condition ) {
evt.stop();
// ...or...
evt.cancel();
}
}, editor, null, -999 ); // by default listeners have priority=10
See CKEDITOR.eventInfo.stop and CKEDITOR.eventInfo.cancel. They're slightly different.
It might be tricky to get why the event is fired as you click to open the dialog box (and to create the right rule), but it feels quite possible. I couldn't reproduce it though (tried latest Chrome and FF); change was fired only when typing or executing commands (like Bold, Link, etc.). If you provided some extra info about your setup (versions of CKEditor and the browser, editor config and the name of the dialog), it would be much easier to debug.
I am loading script into the Ace editor, and upon render, the entire script is highlighted as if someone did a ctrl+a (select all). How do make the contents "unselected" ... seems like it should work that way by default.
Based on documentation, it seems like I could workaround with:
session.getSelection().clearSelection();
... and based on this SO question, it seems I could also do this:
editor.setValue(str, -1) // moves cursor to the start
editor.setValue(str, 1) // moves cursor to the end
Neither work...
You may be able to remove some of the following, it's hard to say without seeing your code, but this should definitely cover it.
editor.setValue('hello world');
editor.clearSelection(1);
editor.gotoLine(1);
editor.getSession().setScrollTop(1);
editor.blur();
editor.focus();
I had the same problem, and I worked around it this way
editor.once('focus', function(){
editor.selection.clearSelection()
})
So it seems that in some cases the editor is not ready yet to accept the command.
In child window of my application, I have placed one single line edit control named as sle_name. Its tab order is 1.
Below that control I have placed DataWindow having formatted as free form style.
When I run the app, if my focus is in sle_name, and I click on sle_name then rbuttondown event is triggered. Then I move my focus to DataWindow(dw_account). Once I got focus on dw_account and then if I try to click on sle_name, my focus is not moving on sle_name and neither I can run rbuttondown event on sle_name.
What is the reason for this problem?
One more thing: when I start this window my focus in set in sle_name, from that control if I press tab key then my focuse moves to dw_account and if I press again shift+tab then my focus is moved back to sle_account.
But if I try to set focus from dw_account to sle_account using mouse pointer it is not moving focus.
What is the reason behind this behaviour?
I had the same behavior in a child window.
It was fixed when disabled the 'ControlMenu' and 'TitleBar' properties in the window. (It's so strange).
Hope it helps
Juanma
This isn't natural behaviour, so the cause is likely something you've scripted. Depending on your architecture, the culprit code could be a number of places (e.g. framework objects). If this were my problem, I'd run with the PBDEBUG trace turned on (a System Option in the IDE, or /PBDEBUG on the command line after the deployed EXE name), and see what is firing when you try to move back to the SLE.
I'd also be using PBL Peeper to see the trace and the code side-by-side, so it's easier to see what code is being executed (the trace only shows you script name and line number).
Good luck,
Terry.
you must have to create the event ID pbm_lbuttonup, with the same parameter as rbuttondown event. Then in the code you write this.setfocus()