blackberry / bbUI.js

BlackBerry UI look and feel JavaScript toolkit for WebWorks
Apache License 2.0
312 stars 192 forks source link

Bug: context menus with image-list and double-quotes #783

Closed listedegarde closed 11 years ago

listedegarde commented 11 years ago

When I have a context menu for an image list with a double-quote in the title or description, the context menu becomes non-functional: 1) The title at the top of the context menu says "Selection" instead of the typical Title and Description. 2) The context-menu disappears, but the selected item remains highlighted after choosing any context-menu option, including cancel. 3) The onclick option for the context menu does not fire.

Things I have tried to solve the issue: 1) Replace double quotes with " or " before writing them to the image-list item. (Does not work) 2) Find the two instances of "item.Node.setAttribute('data-webworks-context', "... in bbUI.js and replace itemNode.[title/description] with itemNode.[title/description].split('"').join('\"') This works, but raises more issues, like back-slashes in the Title and Description.

I'm not quite sure what the correct response to this is. If left as is, an error will occur in _bb10_contextMenu in the "Handle our context open event" function. JSON.parse(data) is unable to parse a string such as in the header: {"id":"bbuiHEX","type":"bbui-context","header":"hello "name"","subheader":"test"}

I'm filing the bug, hoping for suggestions and a permanent resolution to this problem.

tneil commented 11 years ago

I'm going to mark this issue as a duplicate of issue #758. Feel free to add more information to that issue if it doesn't cover your scenario

listedegarde commented 11 years ago

Yes, that definitely looks like a duplicate. Sorry about that. I searched for quite a while before posting. In my solution 1) it was suppose to say Replace double quotes with " and ", (without underscores) which is what you suggested as a solution in bug #758 . The reason your solution does not work is because JSON.parse is parsing for the data-webworks-context attribute of the data-bb-type="item". For example: my data-bb-type="item" would look like this in the Chrome web inspector, edited as HTML (I've removed a couple items to make it more readable and added underscores after the ampersands to keep the exact syntax):

<_div data-bb-type="item" data-bb-title="hello &_amp;quot;name&_amp;quot;" title="hello &_quot;name&_quot;" data-webworks-context="{&_quot;id&_quot;:&_quot;bbui338fd373758eea52d5487e7f1b0e307d&_quot;,&_quot;type&_quot;:&_quot;bbui-context&_quot;,&_quot;header&_quot;:&_quot;hello &_quot;name&_quot;&_quot;,&_quot;subheader&_quot;:&_quot;friend &_quot;}"><_div title="[object HTMLDivElement]" class="bb-bb10-image-list-item-details-720x720 bb-bb10-image-list-item-noimage-720x720"><_div class="title">hello "name"
<_div class="description bb-bb10-image-list-description-light">friend
<_div class="bb-bb10-image-list-item-overlay-720x720"> The problem is that because _bb10_contextMenu is parsing from node.getAttribute('data-weworks-context') where node is equal to the data-bb-type="item", it has to parse from a string that would look like this: {&_quot;id&_quot;:&_quot;bbui338fd373758eea52d5487e7f1b0e307d&_quot;,&_quot;type&_quot;:&_quot;bbui-context&_quot;,&_quot;header&_quot;:&_quot;hello &_quot;name&_quot;&_quot;,&_quot;subheader&_quot;:&_quot;test&_quot;} thus there is a double &_quot; already for the title. Thus, I believe, replacing quotes with &_quot; cannot work in this context.
tneil commented 11 years ago

I just checked in a change that should now fix this issue. Give it a try :o)

listedegarde commented 11 years ago

That was fast, thanks! It's working perfectly so far!

gsk1692 commented 10 years ago

Hello, I'm having a small problem with image list as well... the selected item remains highlighted even after choosing any context-menu option, including cancel. But all the functionalities are working...

tneil commented 10 years ago

Do you have the context menu pre-requisites configured for your application

https://github.com/blackberry/bbUI.js/wiki/Context-Menus#blackberry-10-prerequisites

gsk1692 commented 10 years ago

Yup... As I told you... No issues with the menu at all... After closing the context menu, ie either clicking any function or cancel, the selection area just stays there... If you select a new item, that also gets highlightened...

tneil commented 10 years ago

Right, that's why I asked :) The un-highlight is a function of the extension. If the extension is working properly it should unhighlight the list item.

Can you list the OS version, device you're using, and version of WebWorks that you've built the app with?

tneil commented 10 years ago

The extension only has two purposes, color the context menu with the highlight color and un-select the list item. Can you change your highlight color to something like red to see if it is making the highlight in the context menu red as well?

gsk1692 commented 10 years ago

SDK: 1.0.4.11 OS: 10.2.0.424 Yea... I will check and till you about the colour... Thanks :)

PS: Wont be able to check now.. so it will take time...

gsk1692 commented 10 years ago

Hello... I found the class the class that causes highlightening: class="bb-image-list-item bb-image-list-item-light bb-image-list-item-hover bb10Highlight".... I tried changing it back to class="bb-image-list-item bb-image-list-item-light"...

Then the highlightening disappears... Hope this helps... Thanks again...

gsk1692 commented 10 years ago

Hey the issue is solved...!! Don't know how... Anyway Thank you very much for your time... :)