On Thu, 4 Aug 2022 21:29:49 GMT, Kevin Rushforth <[email protected]> wrote:
>> This PR fixes a bunch of NPEs when a null `SelectionModel` or `FocusModel`
>> is set on a `ListView`.
>>
>> The following NPEs are fixed (all are also covered by exactly one test case):
>> NPEs with null selection model:
>> - Mouse click on a `ListCell`
>> - SPACE key press
>> - KP_UP (arrow up) key press
>> - HOME key press
>> - END key press
>> - BACK_SLASH + CTRL key press
>>
>> NPEs with null focus model:
>> - SPACE key press
>> - Select an items: getSelectionModel().select(1)
>> - Clear-Select an item and add one after:
>> listView.getSelectionModel().clearAndSelect(1); listView.getItems().add("3");
>
> I'd like to see this get resolved for JavaFX 20. I note there is a similar
> issue with `TableView`, which is tracked by
> [JDK-8187145](https://bugs.openjdk.org/browse/JDK-8187145).
>
> As I mentioned in that JBS issue, I tend to agree that if we were starting
> today with a blank sheet of paper, we might have disallowed null and defined
> a "noop" selection model and/or focus model. At this point, though, it would
> be a breaking change, even though we don't specify the behavior of null, so
> we ought to make it work in those places where it doesn't.
>
>> So there is no consistent behaviour for this, but a lot of code already
>> handles null by behaving in some kind of default way without changing the
>> property directly, and I think it might be the best to adapt to this.
>
> This seems like the best way forward to me, but let's see what comes out of
> the review.
>
> As part of this, we should clarify the spec that a null selection (and focus)
> model is allowed, and say what it does. This might mean a CSR, but I'd want
> to look at the current docs first.
Setting selection model to null (i.e. disabling selection) is a fairly frequent
operation, @kevinrushforth .
The code must support that. So no CSR is needed, I think.
-------------
PR: https://git.openjdk.org/jfx/pull/711