Closed Bug 298524 Opened 15 years ago Closed 15 years ago

Add init() method to richlistbox

Categories

(Toolkit :: XUL Widgets, defect)

x86
All
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: doronr, Assigned: doronr)

References

Details

Attachments

(1 file, 1 obsolete file)

 
Attached patch le patch (obsolete) — Splinter Review
Adds init() and 2 other methods.

Also fixes cdata differences (not included in patch :)
+            var lastSelected = this.getAttribute("last-selected");
I'm not sure making a "last-selected" attribute manadatory for this to work is
the way to go though it does work for the EM, etc.

+            if (!lastSelected)
+              this.goDown();
+            else
+              this.selectedItem = lastSelected;
I'm pretty sure that ensureElementIsVisible will not behave as expected when
this is called from startup in extensions.js since the window is not visible
yet. A setTimeout on both of these should do the trick.
It turns out that by calling scrollToElement at the end of init the setTimout is
not necessary. Also, the constructor for richlistitem is rather evil and should
probably be removed... it calls setTimeout(listbox.goDown, 0); once for each
richlistitem added and doesn't provide any value that I can see.
(In reply to comment #3)
> It turns out that by calling scrollToElement at the end of init the setTimout is
> not necessary. Also, the constructor for richlistitem is rather evil and should
> probably be removed... it calls setTimeout(listbox.goDown, 0); once for each
> richlistitem added and doesn't provide any value that I can see.

With my patch and removing the richlistitem constructor, EM selects the right
one when init gets called.  So am confused by your "scrollToElement" comment
(In reply to comment #4)
> With my patch and removing the richlistitem constructor, EM selects the right
> one when init gets called.  So am confused by your "scrollToElement" comment
I have a test profile with 30+ extensions and when I select an extension that is
out of view when the EM is opened, close the EM, and reopen it the extension is
selected but it is one position off out of view as described in bug 298164. This
is without the setTimeout's that get called for each item as they are added
which may be why you are seeing the item when the EM is opened.
Attached patch better patchSplinter Review
Attachment #187067 - Attachment is obsolete: true
Attachment #187140 - Flags: first-review?(mconnor)
Attachment #187140 - Flags: first-review?(mconnor) → first-review+
Attachment #187140 - Flags: approval-aviary1.1a2?
*** Bug 298164 has been marked as a duplicate of this bug. ***
Attachment #187140 - Flags: approval-aviary1.1a2? → approval-aviary1.1a2+
checked in
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
I should have been more specific when I suggested using scollToElement... this
should only be called in init and not when setting selectedItem. When selecting
an item it should only scroll when an item that is being selected is not in view
and with scrollToElement it always scrolls the selected item to the top.
(In reply to comment #9)
> I should have been more specific when I suggested using scollToElement... this
> should only be called in init and not when setting selectedItem. When selecting
> an item it should only scroll when an item that is being selected is not in view
> and with scrollToElement it always scrolls the selected item to the top.

oops, good catch
You need to log in before you can comment on or make changes to this bug.