Setting dataprovider in Combobox freezes the UI - actionscript-3

I am using a Combobox component for a category dropdown in my application. But on loading the page, if I click on the category dropdown the UI freezes. There are no errors in the console. I have this code in my commit properties.
if (_categoriesChanged)
{
_categoriesChanged = false;
categoryCombo.dataProvider = categories;//If i comment out this line, everything works normal
setSelectedCategory();
}
I have similar usage of combobox elsewhere in the application and I have no issues.
Also this doesn't happen if I put a breakpoint and go step by step (hence can't debug too).
Anyone with any idea?

Related

Disable tooltips in Chrome DevTools Sources tab

With Chrome DevTools open I can place a breakpoint in a Javascript file and step through the code displayed in the "Sources" tab as it executes. The problem is that every time I hover over a variable I get an unwanted tooltip that pops up with the value of that variable.
For example if a section of code is let a = 1; then any time my cursor happens to pass over a I get a popup displaying 1. Some variables such as DOM elements can be quite large and frequently get in the way as I am trying to look at the code. I find this annoying and would like to disable this feature. Is there a way to NEVER see these tooltips?

Chrome Extension -- Running executeScript in multiple new tabs at the same time

I'm building a Chrome Extension that has a popup.html with a search form. Like Travelocity or Kayak, the form includes checkboxes so the user can select which sites they want to query.
On submit, popup.js launches multiple new tabs based on the selected checkboxes. In the tabs.create() callback for each new tab I use executeScript to:
- (A) inject the user's query into the search form on each of the new pages, and
- (B) submit the search form on those pages.
My code is working when one checkbox is selected (i.e. new tab is launched), but when multiple new tabs are created simultaneously it appears that the executeScript isn't running consistently. Sometimes it works, and sometimes it doesn't.
This leads me to believe that there's some sort of issue with the timing of the script execution, but I'm not sure.
If you have any idea what's going on I'd love to hear your advice.
Also, I'd appreciate any resources on how to debug this sort of issue in the future.
Here's my code on github...
whole repo: https://github.com/rossmorey/SongSearch
manifest.json
popup.html
popup.js (most relevant file)
Many thanks!
Seems like when you open multiple tabs - your popup.html loses the focus and closes, so on tabs.create callbacks which injects your code will not be executed.
Try to create tabs with "active:false" option, like this:
chrome.tabs.create({url: stringToObj[org], active:false} ...
I think it would help you.
And also...
It's a bug in your SeSac inject-code: if no search type defined in popup window, block
input[value="undefined"]
will not be found, so "checked" property will be called on "undefined" and this will stop you inject script execution.

AngularJS 1.5- <select> element displays dropdown at incorrect times (iOS 10 only)

As you can infer from the title, this is an interesting & frustrating bug. I have a normal select element in an Angular partial with the following code:
<select ng-options="availweek.weekNumber as availweek.weekNumber for availweek in availableWeeks | orderBy: 'weekNumber':'reverse'"
ng-model="selectedWeek.weekNumber"
ng-change="viewPrevWeek(selectedWeek.weekNumber)"
style="color: black">
</select>
This element displays a list of numbers (representing weeks) and triggers the viewPrevWeek function when one is changed. That function is below- it just passes the week and reloads the partial to reflect data relevant to the selected week:
$scope.viewPrevWeek = function (week) {
if (week <= $scope.totalWeeksAvailable) {
$localStorage.active_week = week;
$state.reload();
}
}
My issue is that, on iOS 10 only, if a user changes the selected week via the dropdown (thus triggering viewPrevWeek), the dropdown will then pop up on any click of any button in the rest of the app.
This is precisely as annoying as it sounds- so if a user selects a something in the dropdown and decides to navigate to a new page, the dropdown reappears when clicking to expand the nav. The behavior is as if the dropdown retains focus after selection, so any click in the app also registers as a click on the dropdown, which causes the selector to open.
This only occurs if the week is actually changed- if the user opens the dropdown and selects the choice that was defaulted at page load, this doesn't happen.
I'm at a loss for how to get to the bottom of this- it doesn't occur on Android phones, nor when I use Chrome or other dev tools to force a phone screen resolution on desktop. It occurs on both Safari and Chrome in iOS 10, and doesn't occur in either browser in iOS 9 - so I'm pretty sure this is related to changes in iOS 10.
Not sure if you've solved this one yet, but we had the same problem and came up with a fix.
It seems that iOS 10 has something funky going on in the time between the native dropdown closing and when the code in your ng-change method gets fired. We found that the browser acted like the dropdown was still open and would trigger again when clicking any link, despite our ng-change event firing correctly.
We drew some inspiration from this thread: https://stackoverflow.com/a/24056865/542124 and set a timeout inside our method. This allows for iOS to finish closing the native dropdown UI, and finish whatever else it needs to do, before executing our code. In your example, this is how we would approach it;
$scope.viewPrevWeek = function (week) {
if (week <= $scope.totalWeeksAvailable) {
$timeout(function() {
$localStorage.active_week = week;
$state.reload();
}, 1000);
}
}
We'll give it a second to finish, show some sort of loading spinner to signify to the user that something is happening, and that should allow enough time to pass to resolve the issue.

show page action popup on click

I'm making a chrome extension that uses pageAction.
I can set when it shows whether I want it to have a popup or handle the click myself.
What I want to do is handle the click myself, but with certain scenarios I don't want to process the normal code, and want to show the user a message. Preferably with a popup.
But it seams I can either make the pageAction have a popup or have an onClick. But not both.
I can show an alert, but that is ugly.
Currently, there is no "neat" or official way to handle both. You can just do either. But there are some work arounds that some Google extension product have done.
First of all, set it up to show the popup. And within your pageAction popup, you can have the initialization code to be something like this:
Page Action Popup:
function init() {
if (getClickBehaviour() == 'popup')
handlePopup();
else
openPage();
}
function getClickBehaviour() {
return localStorage['CLICK_BEHAVIOR'] || 'popup';
}
function openPage() {
chrome.tabs.create({url: 'http://google.ca'});
window.close();
});
}
init();
Then you can let your options, set the click behavior. If you want different behaviors on each click, you can do that too.
As you noticed, we are closing the popup right after for the "default" behavior that we don't want the popup to show. That is currently the only way to implement different behaviors.
I haven't tested this myself yet, but have you tried setting the popup to the empty string when you want to handle the click (chrome.pageAction.setPopup('')) and to your popup when you want to show a message. I'm not perfectly sure if the onClicked event handler gets called in that case (where the popup is dynamically set to the empty string), but it's worth looking into.
As far as I know, there is generally no way to programmatically open a popup window for a page or browser action. (Which is too bad, I would love this functionality; but you can imagine some of the annoyances if this were possible.)

How do I focus an existing tab in a window? (web page, not extension)

I'm trying to focus an existing tab when the content reloads. The usual window methods don't seem to work.
Here's whats happening: On page_1 I have a link like...
Go to my other page
If the tab doesn't exist, when the link is clicked it opens a new tab and takes focus. (Perfect)
If you then go back to page_1 and click the link again, it reloads the content in the existing tab (perfect) but doesn't focus (crap). I've tried the usual window.focus, $(window).focus methods on load with page_2 without luck.
Any recommendations?
It is impossible.
The following appears to work in IE8 and FF13:
<script type="text/javascript">
// Stupid script to force focus to an existing tab when the link is clicked.
// And yes, we do need to open it twice.
function openHelp(a) {
var tab = window.open(a.href, a.target);
tab.close();
tab = window.open(a.href, a.target);
return false;
}
</script>
Help
There is a workaround to this. Use javascript to open a window in a new tab, store a reference to that tab, and when you want to focus it; close it first and then re-open it.
if (window.existingWindow != null)
try { window.existingWindow.close(); } catch (e) { };
window.existingWindow = window.open("/your/url", "yourTabName");
We use a similar approach to opening the preview pane of the current page you're working on in our service called Handcraft where the above works as expected (we wanted the new window to always focus).
Without using a framework you can put a script block at the bottom of your page that will run once the page loads. Because it is after your HTML you can be assured that the HTML is refers to is actually available.
The script can set the focus to the element you want.