Opened 8 years ago

Closed 7 years ago

#14453 closed defect (fixed)

[patch][ccla] Regression in dojox.form.Rating

Reported by: eabe Owned by: bill
Priority: high Milestone: 1.8
Component: DojoX Form Version: 1.6.1
Keywords: dojox, form, rating Cc: cjolif
Blocked By: Blocking:

Description

The widget works fine on an old dojox.form.Rating example: http://wolfram.kriesing.de/dojo/dojox/widget/tests/test_Rating.html

But it is slightly broken on a newer example: http://download.dojotoolkit.org/release-1.7.0/dojo-release-1.7.0/dojox/form/tests/test_Rating.html

How to reproduce:

  1. Open the test page
  2. Slowly mouse over the Rating widget from left to right

-> on 1.7 (and 1.6), the mouse over visual feedback will only start on the second star

  1. Continue the mouse over from left to right until the last star

-> on 1.7 (and 1.6), the mouse over visual feedback will not disappear when the mouse goes away

According to my debug, the Rating widget relies on "this.hovering" flag to detect the mouse hover state (the "hovering" flag was set before "onmouseover" and "onmouseout" listeners were called).

With Dojo 1.6 onward, the value of the "this.hovering" flag from "onmouseover" and "onmouseout" is not consistent with previous Dojo versions, possibly because the order in which listeners are called has changed.

In order to comply with the 1.6 change, the Rating widget must be updated to proper detect mouse over and mouse out events:

--- C:/Users/IBM_AD~1/AppData/Local/Temp/Rating.js-revBASE.svn000.tmp.js	Mon Dec 12 15:22:11 2011
+++ D:/home/eabe/devel/ibm/dojo/dojo-toolkit-readonly/dojox/form/Rating.js	Fri Dec  9 18:22:55 2011
@@ -43,7 +43,7 @@
 					'<input type="hidden" value="0" dojoAttachPoint="focusNode" /><ul>${stars}</ul>' +
 				'</div>';
 		// The value-attribute is used to "read" the value for processing in the widget class
-		var starTpl = '<li class="dojoxRatingStar dijitInline" dojoAttachEvent="onclick:onStarClick,onmouseover:_onMouse,onmouseout:_onMouse" value="${value}"></li>';
+		var starTpl = '<li class="dojoxRatingStar dijitInline" dojoAttachEvent="onclick:onStarClick,onmouseover:_onMouseOver,onmouseout:_onMouseOut" value="${value}"></li>';
 		var rendered = "";
 		for(var i = 0; i < this.numStars; i++){
 			rendered += string.substitute(starTpl, {value:i+1});
@@ -56,15 +56,15 @@
 		this._renderStars(this.value);
 	},
 
-	_onMouse: function(evt){
-		if(this.hovering){
-			var hoverValue = +domAttr.get(evt.target, "value");
-			this.onMouseOver(evt, hoverValue);
-			this._renderStars(hoverValue, true);
-		}else{
-			this._renderStars(this.value);
-		}
+	_onMouseOver: function(evt){
+		var hoverValue = +domAttr.get(evt.target, "value");
+		this.onMouseOver(evt, hoverValue);
+		this._renderStars(hoverValue, true);
 	},
+	
+	_onMouseOut: function(evt){
+		this._renderStars(this.value);
+	},
 
 	_renderStars: function(value, hover){
 		// summary: Render the stars depending on the value.

I hope that this report will be helpful in addressing / solving this issue.

Thanks, Eduardo Abe

Attachments (1)

rating.diff (1.5 KB) - added by eabe 8 years ago.
Diff illustrating a possible fix for this problem.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by eabe

Attachment: rating.diff added

Diff illustrating a possible fix for this problem.

comment:1 Changed 8 years ago by cjolif

Cc: cjolif added

comment:2 Changed 7 years ago by Nick Fenwick

This fixed the problem for me on 1.7.1. What's the holdup getting this approved and merged?

comment:3 Changed 7 years ago by cjolif

Summary: Regression in dojox.form.Rating[patch][ccla] Regression in dojox.form.Rating

comment:4 Changed 7 years ago by bill

Milestone: tbd1.8
Owner: changed from dante to bill
Status: newassigned

The patch doesn't apply anymore but I'll work something out.

comment:5 Changed 7 years ago by bill

Resolution: fixed
Status: assignedclosed

In [29299]:

Fix hover effect on Ratings widgets, and upgrade code to use dojo/on and event delegation, and Stateful pattern. Fixes #14453 !strict.

Note: See TracTickets for help on using tickets.