jQuery UI 1.8rc1 bug in $.ui.position collision "flip"

jQuery UI 1.8rc1 bug in $.ui.position collision "flip"

The collision handling code for flipping left can be found on line 8319 of jquery.ui.js. At the very top of the function is this check:
  1. if (data.at[0] == 'center')
  2.     return;
which causes the flip to fail if we want to position some element at the horizontal center of the target. I believe this check should be:

  1. if (data.my[0] == 'center')
  2.     return;

which would cause the flip to fail if we're positioning my horizontal center, in which case a horizontal flip would not change the position.

Consider the case where we're using a tooltip on anchor tags, and we want to position the tooltip's (data.my) left bottom at the target anchor's (data.at) center top. If the anchor appears at the right edge of the screen, we'll need to flip the tooltip to the left. With the current check, this will fail because we're positioning at the anchor's center (but there's no reason that should cause the flip to fail-- in this case it causes the tooltip to be positioned overlapping the edge of the window). With my proposed change, we would only abort if we were positioning the tooltip's horizontal center, in which case a flip would not change the position.

Edit: It looks like the flip.top function has the same problem. data.at should be data.my.
    • Topic Participants

    • bryan