[
https://issues.apache.org/jira/browse/FLEX-34222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15010903#comment-15010903
]
Tamás Nepusz commented on FLEX-34222:
-------------------------------------
I'm probably a bit late to the party here but here's an analysis of the problem
the way I understand it.
In {{ComboBox.as}}, there is a branch in {{setSelectedIndex()}} that
force-updates the text shown in the text field *if* {{userTypedIntoText &&
value == selectedIndex}}, probably to cater for cases when the user types some
text into the combo box and then changes her mind and decides to select the
entry corresponding to the old selection (that was active before she started
typing). In this case, we have to update the text field to ensure that the
selected value is shown there (since {{setSelectedIndex()}} in {{ListBase}}
will short-circuit because the selected index stayed the same).
The problem is that this is done even when the old and the new selected index
are both {{CUSTOM_SELECTED_ITEM}} - in that case, we should *not* update the
label display from the *current* selected item (which has not been updated
based on the new text entered into the text field yet).
It is not trivial to work around this without modifying {{ComboBox.as}} - my
approach uses a private flag named {{_preventLabelDisplayUpdates}} that is set
to {{true}} when {{setSelectedIndex}} is called with {{CUSTOM_SELECTED_ITEM}}
and the current {{selectedIndex}} is also equal to {{CUSTOM_SELECTED_ITEM}}. I
also had to override {{updateLabelDisplay}} (which is luckily not {{private}}
but {{mx_internal}}) to check this flag and return immediately (after clearing
the flag) if the flag is set.
This seemed to do the trick for me but I don't know whether it breaks any test
cases or not.
> Entering values into ComboBox not present in dataProvider does not work
> -----------------------------------------------------------------------
>
> Key: FLEX-34222
> URL: https://issues.apache.org/jira/browse/FLEX-34222
> Project: Apache Flex
> Issue Type: Bug
> Components: Spark: ComboBox
> Affects Versions: Apache Flex 4.12.0
> Reporter: Aleksey
> Labels: easytest
> Fix For: Apache Flex 4.13.0
>
>
> An example:
> {code}
> <?xml version="1.0"?>
> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx">
> <s:ComboBox id="test">
> <s:dataProvider>
> <s:ArrayList>
> <fx:Number>2</fx:Number>
> <fx:Number>4</fx:Number>
> <fx:Number>6</fx:Number>
> <fx:Number>8</fx:Number>
> </s:ArrayList>
> </s:dataProvider>
> </s:ComboBox>
> </s:WindowedApplication>
> {code}
> First type in "3" press Enter, type in "5" and press Enter - displayed value
> changes back to "3".
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)