RFR: 8295248: JEditorPane HTML form with multi-selection broke data after resetting [v3]
Toshio Nakamura
tnakamura at openjdk.org
Thu Jan 26 09:18:22 UTC 2023
On Mon, 24 Oct 2022 02:06:23 GMT, Toshio Nakamura <tnakamura at openjdk.org> wrote:
>> When JEditorPane shown HTML form with multi-selection, the reset operation broke its data.
>>
>> The sample testcase were attached in JBS. The recreate steps are below:
>> 1. The sample shows a multi-selection form with 5 items.
>> 2. Select the 4th item.
>> 3. Press the reset button.
>> Actual: The 4th item is still selected.
>> Expect: No item should be selected. Resetting operation may move to the initial state. The sample doesn't use 'selected' property in each option tag.
>> 4. Just after the step 3, move the focus to outside of the application and back.
>> Actual: The 2nd item is selected. It means inside data indicates so.
>> Expect: No item is selected.
>>
>> There are two issues. The current method `OptionListModel.removeIndexInterval()` removed the indexed item, and shifted the rest. Then, selection values were corrupted.
>> I think the clear selection method `OptionListModel.clearSelection()` is suitable here.
>>
>> Test: jdk_desktop on macOS (x64, Monterey), Linux (x64, RHEL8), and Windows (x64, 2012R2).
>> No regression found
>
> Toshio Nakamura has updated the pull request incrementally with one additional commit since the last revision:
>
> Fixed space
(Reopened this PR.)
Let me re-explain the problem.
Currently, the reset action of HTML form uses `javax/swing/text/html/OptionListModel#removeIndexInternal`. It removes the indexed value. When a multiple selection form has 5 items, the method worked like below.
for (int i = 0; i < size; i++) {
removeIndexInternal(i,i)
}
i - item values
0 - (1) 2 3 4 5 - remove 1st item and shift
2 3 4 5 x
1 - 2 (3) 4 5 x - remove 2nd item and shift
2 4 5 x x
2 - 2 4 (5) x x - remove 3rd item and shift
2 4 x x x
3 - 2 4 x (x) x
4 - 2 4 x x (x)
At the end, 2nd and 4th values remain even after resetting.
The intention of the function may clear all items, and `clearSelection` method can be appropriate.
-------------
PR: https://git.openjdk.org/jdk/pull/10685
More information about the client-libs-dev
mailing list