locked
SearchBox causes "Unspecified error" when leaving the page

    Question

  • Hi all,

    I've switched off the SearchPane in my app to implement a SearchBox, everything works as I want except that whenever I leave the page containing the SearchBox, an exception ("Unspecified error") is thrown by ui.js at line 44580: 

    if (createFilled && this._inputElement.msGetInputContext && this._inputElement.msGetInputContext().getCompositionAlternatives) {

    It's in SearchBox's _getLinguisticDetails() function, it tries to execute the msGetInputContext() on the <input> element which is present but raises an "unspecified error".

    I've read on the web that such an error is usually raised when trying to do something forbidden but I really don't see what could be forbidden here...

    Thanks in advance!

    Thursday, September 25, 2014 3:43 PM

Answers

  • As a quick and dirty workaround, I've done the following in the unload function of both of my pages having SearchBoxes :

    searchBox._inputElement.msGetInputContext = null;
    I can't find another for now since I really don't know why the <input> fires that extra event... :(

    Friday, September 26, 2014 10:33 AM

All replies

  • Hi Pierre,

    What is your purpose for execute the msGetInputContext(), you want to get current input text, you may use queryText instead.

    Anyway, you mentioned whenever leave the page, and I can see a word from MSInputMethodContext documentation: Once created, the lifetime of the MSInputMethodContext object is tied to the lifetime of its corresponding element. 

    Simply guess it might because MSInputMethodContext cannot react to the page navigation? Would you like remove the removeEventListener before you leave the page?

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 26, 2014 2:43 AM
    Moderator
  • Hi Jamles,

    Thanks for your answer.

    I don't execute this function myself, it's just that this function causes the error inside the SearchBox code in ui.js.

    I've just added in the page's unload function removeEventListener() for the two event listeners I add to the SearchBox before calling dispose() on the SearchBox: the error is still there. :(

    I've also tried to add "Search" in the declarations of the appxmanifest but it doesn't change anything.

    This error doesn't crash my app, it is invisible for the user, but it forces the debugger to break every time I leave the first page of the app which is a pain. Also, I don't think having an exception every time should be a normal behavior for an app.

    Pierre

    EDIT: after further investigation, the function that causes the error is executed by the SearchBox's <input> element which fires a "input" event when the page unloads, is it normal that this event is triggered when unloading the control?
    Friday, September 26, 2014 8:37 AM
  • Hi Pierre,

    Yes, I totally agree a normal app should not have exception.

    It looks like the problem is on SearchBox control itself. To ensure this, could you try to execute the (JavaScript) app from: http://code.msdn.microsoft.com/windowsapps/SearchBox-control-sample-0f64f94d to see if you can have the same exception happen.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 26, 2014 9:19 AM
    Moderator
  • No, I can't reproduce the rror outside my app so it must be something that I do somewhere but I really don't know what...

    I've just added a SearchBox to a blank "split app" generated by the VS template and it doesn't raise any error when leaving the page.

    Friday, September 26, 2014 10:22 AM
  • As a quick and dirty workaround, I've done the following in the unload function of both of my pages having SearchBoxes :

    searchBox._inputElement.msGetInputContext = null;
    I can't find another for now since I really don't know why the <input> fires that extra event... :(

    Friday, September 26, 2014 10:33 AM
  • I believe there might be some mis-setting on your current app or you have some API overridden.

    is it normal that this event is triggered when unloading the control?

    -> I don't think it is normal, as we can see if we use the searchbox with a blank app, everything works perfect, I may want to check if I have some event trigger on the textbox somewhere in my code.

    Anyway, at least you find a dirty solution, not sure it is a perfect one, but at least it works.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Sunday, September 28, 2014 7:25 AM
    Moderator
  • Ok, thanks for your time, James!

    If I ever find what's wrong, I'll post the solution here.

    Pierre

    Monday, September 29, 2014 1:11 PM