I am experiencing some unusual behaviour with AntD InputNumber component, specifically using the up/down incrementation buttons:
I have a very basic implementation of the component as follows:
<InputNumber min={1} max={10} defaultValue={3} onChange={changeWeight} />
calling function:
function changeWeight(weight) {
console.log(weight);
}
On the face of it, it all seems to work fine, as I click on the increment button, I see the result in my console for each click. 3 clicks up and my console reads:
Great! However, if I then place a debugger inside the called function like so:
function changeWeight(weight) {
debugger;
console.log(weight);
}
then refresh the screen and hit the increment button once, I hit my breakpoint, console is logged, I hit continue then instead of the process finishing, it goes straight back to the breakpoint again. The function is called again and again infinitely it seems. I have found if you put a max value on the InputNumber component it does stop at that number. The below console log is from hitting the button just once, but the breakpoint being hit many times...
Again, if I remove the debugger breakpoint, all seems normal and the console logs just the once when the button is clicked.
Also, if I type numbers into the component it only hits the debugger breakpoint once. Just these buttons seem to be causing a problem.
Has anyone else experienced this or have any ideas as to what may be causing it? I am very confused.
Related
I have created a simple TicTacToe using react-hooks.
Sometimes I am getting result before my state update is shown on screen.
Sometimes it is showing result after update is shown on screen.
I am not getting why it is reacting in 2 different ways.
Please find the code link below.
playground link
alert() function is blocking function so when alert window opens your app is on pause until user hit ok button.
alert function can sometimes race with rendering, that's why sometimes the alert shows before the last render and your app on pause so you will not see the change on the grid.
it happens when you
The solution is to replace alert() whith another visual element such as modals
Issue probably comes from your useState, you can try adding dependency array for the useState with player change so it only checks the game after each round.
From:
useEffect(() => {
CheckGame();
});
To:
useEffect(() => {
CheckGame();
}, [player]);
I have a Sencha Touch 2.3.1 application in which the message box does not respond sufficiently to Ext.Msg.hide() after showing and hiding the message box several times, but not at a consistent rate.
It seems to get into a state where, if I call Ext.Msg.alert('foo') and then call Ext.Msg.hide(), the message box will update with the 'foo' text and the semi-transparent mask will hide when hide() is called, but the message box won't go away and Ext.Msg.isHidden() returns true.
Here's the crazy part: I can only reproduce this by calling the same methods repeatedly and manually. I tested this by running the following endless interval in my console:
var j = 0;
var c = setInterval(function(){
if(++j % 2 == 0)
Ext.Msg.alert('Run ' + j);
else
Ext.Msg.hide();
}, 500)
As the above interval runs through hundreds of iterations, I have no issues whatsoever. The modal window opens and closes as expected. However, when I manually run Ext.Msg.alert('foo') and then Ext.Msg.hide() in the console in approximately 500ms intervals, the message box will consistently get stuck within 20 iterations.
Does anyone have the slightest clue as to how this could be debugged or what's causing this?
This is fixed. See in the sencha forum
see fix here:
I'm writing some code to test IOS app using X-code and instrument. I want to check the state of a button when it toggle on/off. I try using method .isEnabled() to check if it's on/off but it fails to determine the state. In other words, instruments always passes the line "if (mainWindow.popover().buttons()[17].isEnabled())" regardless tapping the button or not.
here's part of my code:
//Button is OFF as default
//Tap to turn it ON
mainWindow.popover().buttons()[17].tap();
//Have a short delay to ensure it changes state
target.deday(1);
//Check to see if it's ON
if (mainWindow.popover().buttons()[17].isEnabled()) {
UIALogger.logMessage("button ON");
}
...
The root cause of this issue is that the button does not return any value when it toggles ON/OFF. It should return value 0 if it's Off and 1 if it's ON. I'm working out this issue with dev team.
BTW, I also mis-understood the function .IsEnabled() as it only checks if a button is able to tap or not. The function returns false if a button is greyed out (could not be tap). Otherwise, it should return true :)
I have a phonegap project on iPhone and Android. The issue appears to be a race condition on the surface, but I don't understand how it happens. Users are able to click on a button which has a closure callback that sets a property of an object, and then clears the screen and loads the main menu. In code:
button.onclick = function (employee) {
return function () {
employee.task = "some task";
returnToMenu();
}
}(employees[i]);
After the user is back on the main menu, they can click on a button that loads a screen which displays all the users. If an employee has that task property set, additionally formatting should be done to the button for that employee.
if (employee.task)
// style the button being created for this employee
Somehow, if one clicks fast enough, the formatting is not done. If you click back (to the main menu), and reload the screen, the formatting is now done. Given the code above, I do not see how employee.task could possibly return undefined after the menu has been loaded. What's going on here?
I try to understand Firefox's behavior regarding the added "prevent this page from creating additional dialogs" on dialog boxes.
Using jquery, if I add the following listeners :
//html
<input class="testInput" />
//javascript
$('.testInput')
.click(function(){ alert('clicked') })
.keyup(function(){ alert('keyup') })
When clicking on the input, the alert box appears normally, until the
~13th time.
When hitting a key, on the other hand, the second message box already
appears with the message "prevent this page from creating additional
dialogs". Actually, there seems to be some tiemout, and if I wait
like 2 seconds between two keystrokes, the message disappears.
From my informal tests, 2. actually applies whenever the alert box is not called from within a onclick callback (e.g : keyup callback, displaying an alert box in answer to an ajax action...)
I am using Firefox 9.0.1 under Ubuntu, as far as I know I haven't tweaked firefox's settings regarding these thresholds.
I imagine it happens with any recent version of any browser.
I am using the jQuery library, but I don't think it is relevant here.
My question is :
What are the exact rules which make this warning appear in a dialog box ?
[Edit]
Using Chromium/Ubuntu (version 17.0.963.26), the threshold seems to be only the delay between two dialog boxes.
You can test this from jsfiddle here (thx Rory McCrossan)
The exact rule(s): A timed interval between the dialog boxes popping up.
The value used to determine this is set in SUCCESSIVE_DIALOG_TIME_LIMIT
Check out line 2614 in the link below the snippet:
nsGlobalWindow::DialogOpenAttempted()
TimeDuration dialogDuration(TimeStamp::Now() - topWindow->mLastDialogQuitTime);
if (dialogDuration.ToSeconds() < Preferences::GetInt("dom.successive_dialog_time_limit",SUCCESSIVE_DIALOG_TIME_LIMIT)){topWindow->mDialogAbuseCount++;return (topWindow->GetPopupControlState() > openAllowed || topWindow->mDialogAbuseCount > MAX_DIALOG_COUNT);}topWindow->mDialogAbuseCount = 0; return false;}
Link to source
You can kick around the Firefox source if you like. Note that different browsers will have different rules.
The relevant code for Firefox is in nsGlobalWindow.cpp and nsGlobalWindow.h (the links below are to line numbers, and so will slowly rot as the source changes). It appears to be controlled by the constants MAX_DIALOG_COUNT (10) in nsGlobalWindow.h and SUCCESSIVE_DIALOG_TIME_LIMIT (3, units are seconds). nsGlobalWindow.cpp keeps a count (mDialogAbuseCount). Apparently, the dialogDuration function either increments or clears mDialogAbuseCount depending on whether the dialog has been open longer than the SUCCESSIVE_DIALOG_TIME_LIMIT. The AreDialogsBlocked function uses the mDialogAbuseCount (in part) to decide whether they're blocked.
So in short: If you're repeatedly opening pop-ups and then closing them within three seconds, after 10 or so you'll trigger something.