Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null values to be treated as deselect options. #245

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

awaters-escribe
Copy link

When a renderer doesn't render null as an empty string "" the setting allowSingleDeselect doesn't take effect. Therefore, when ChosenValueListBox encounters a null value it passes an empty string as
the list box item's value. ChosenImpl now looks at the element's value attribute to detect this, while keeping the old functionality operational.

@olafleur
Copy link
Member

It seems we have a failing test in master. I'll check that.

@olafleur
Copy link
Member

The test that is failing is tabNavigation in ChosenIT.
I think it's because you are changing the behaviour of ChosenValueListBox.

Could you fix the failing test or make sure that it still passes (depending on what is relevant)?

@awaters-escribe
Copy link
Author

On my local machine the test fails from master, I'm not sure if it is a version issue with Chrome/ChromeDriver, can you force a rebuild of master in team city to rule that out?

@olafleur
Copy link
Member

Still failing after forcing the rebuild.

@meriouma
Copy link
Member

What's the use case? I'm not sure I understand why you cannot use the current placeholder functionality?
You want to allow "" value to have the same meaning as null for the placeholder?

@awaters-escribe
Copy link
Author

master fails on the same test http://teamcity.arcbees.com/viewLog.html?buildId=6239&tab=buildResultsDiv&buildTypeId=GwtChosen_MonitorPulls.

The issue is that in order for allowSingleDeselect to actually be active the first item in the needs to have "" as its text, this is so there is an item to deselect to. When using ChosenValueListBox that means he renderer needs to render the first value as "", usually this is accomplished by inserting a null into the list and having the renderer render null as "". However, in the application I am developing the renderer renders null as "Select One". This breaks allowSingleDeselect because the text is no longer "", but is still the item to deselect to. This change makes it so that when a null value is passed into ChosenValueListBox it changes the value to "", but leaves the text the same as the render. Then I changed ChosenImpl to look at getValue(). Since getText() == getValue() when using the single argument addItem() this change does not break the old way that it worked.

}

/**
* Goal: ensure allowSingleDeselect shows the X/cross when there is a value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkstyle is complaining that your sentence does not end with a period. @meriouma I didn't know checkstyle was so picky! ;-)

@meriouma
Copy link
Member

It seems you are doing this pull request to bypass how the placeholder is handled.
You are using the renderer to render a value as the placeholder, but in reality, you should use the setPlaceholderText on your ChosenOptions.
@jDramaix Thoughts?

@awaters-escribe
Copy link
Author

This is separate from a placeholder. With ChosenValueListBox one must add a null value to acceptable values in order to have something to deselect to. Therefore the first item in acceptableValues is null. Now, before my change, ChosenImpl would only select the null value if it rendered as "" (an empty string). In my application null is rendered as "Select One", while the merits of rendering null as "" or "Select One" can be debated, I won't touch on that subject. This change makes it so a null value has its form value as "", and ChosenImpl is updated to check the form value instead of the text of the rendered item.

See

public void setAcceptableValues(Collection<T> acceptableValues) {
for more details about null being in the list.

@awaters-escribe
Copy link
Author

Can I get some feedback on this? It is documented and fully tested, what else are you guys looking for?

@christiangoudreau
Copy link
Member

@jDramaix to review

@olafleur olafleur closed this Dec 1, 2015
@olafleur olafleur reopened this Dec 1, 2015
@jDramaix
Copy link
Contributor

jDramaix commented Dec 2, 2015

seems pretty straightforward. LGTM

@olafleur
Copy link
Member

@awaters-escribe could you fix the conflicts? After that we could merge that PR as we have an LGTM from @jDramaix

When a renderer doesn't render null as an empty string "" the setting
allowSingleDeselect doesn't take effect.  Therefore, when
ChosenValueListBox encounters a null value it passes an empty string as
the list box item's value.  ChosenImpl now looks at the <option>
element's value attribute to detect this, while keeping the old
functionality operational.
@bartmoc bartmoc force-pushed the master branch 2 times, most recently from a34560c to e20e47b Compare April 11, 2016 16:41
@ewolk
Copy link

ewolk commented Apr 12, 2016

@jDramaix @olafleur merge conflicts have been fixed, and pr rebased on the latest.

the tests that are failing are:
DesktopChosenIT.allowSingleDeselect MobileChosenIT.allowSingleDeselect
it is unclear from here whether these tests should be failing or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants