Ipywidgets: SelectMultiple jumps

Created on 4 Sep 2017  路  8Comments  路  Source: jupyter-widgets/ipywidgets

Hi,

I've recently upgraded to ipywidgets 7.0.0. The new behaviour of SelectMultiple is at least distracting. If I have a long list of options and I select an option in the middle of it, the select scrolls so that the selection is at the bottom. That leads to constant jumps and I need to manually scroll to find the positions I want to be in. I suspect it is a desired behaviour, but I'd propose to add an option to disable it. Presently, I could not find anyway to disable this behaviour.

bug good first issue controls

All 8 comments

Thanks for raising an issue. I'm struggling to reproduce this. I tried:

import ipywidgets as widgets

s = widgets.SelectMultiple(options=['option-{}'.format(i) for i in range(50)])
s

Selecting by clicking the mouse on an option in the select box doesn't cause any scrolling on Chrome 60.

It would be great if you could add the following information:

  • What browser are you using? (in general, the behaviour of DOM widgets can be quite browser dependent, so always giving browser information is useful)
  • "If I have a long list of options and I select an option in the middle of it" -- how many options / can you provide the actual option values?
  • "I select an option in the middle of it" -- Do you mean by clicking on the option, or by selecting it programatically?

This minimal example does reproduce my problem for my setup.

  • Browser: firefox 53 (64 bit). Mozila Firefox for Linux Mint. mint-1
  • your example reproduces the problem. I'm routinely using above 100
  • I mean selection by clicking

Great, thanks -- I can reproduce this in Firefox 54 on Mac OS, so the behaviour seems to be browser dependent.

I don't think this is intentional behaviour. A priori, it doesn't look like we're doing anything special to the select that would cause this. For anyone wanting to tackle this, maybe a good starting point would be to try and reproduce this behaviour in plain html (outside of the context of widgets).

As a side info, I was using ipywidgets 5.0 up to now and the behaviour was different. If this helps.

@jasongrout / anyone else. I tentatively labelled this as 'bug' and 'sprint friendly' (since it seems fairly isolated to the SelectMultiple widget) but feel free to change classifications, obviously.

seems fine to me 馃憤

Here's a guess at what is going on:

  1. When clicking to do a selection, https://github.com/jupyter-widgets/ipywidgets/blob/1bc4a6765565fe39290c4007a3c77a4639bf3c75/packages/controls/src/widget_selection.ts#L789 is run, which sets the selected index. This causes https://github.com/jupyter-widgets/ipywidgets/blob/1bc4a6765565fe39290c4007a3c77a4639bf3c75/packages/controls/src/widget_selection.ts#L770 to run, which resets the selected index programmatically. Somehow in older browsers like noted above, that causes a scroll in the select box. One possible solution is to pass in an argument to the model index set giving the view doing the selection, and then in the update method checking to see if that is the current view. That's a pattern we use several other places, like https://github.com/jupyter-widgets/ipywidgets/blob/1bc4a6765565fe39290c4007a3c77a4639bf3c75/packages/controls/src/widget_selection.ts#L542

I also reproduced it in Firefox. Fix is over on #1713.

Was this page helpful?
0 / 5 - 0 ratings