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

Setting readonly still allows deleting chips #34

Closed
thomasdewaelheyns opened this issue Feb 4, 2021 · 11 comments
Closed

Setting readonly still allows deleting chips #34

thomasdewaelheyns opened this issue Feb 4, 2021 · 11 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@thomasdewaelheyns
Copy link

thomasdewaelheyns commented Feb 4, 2021

Setting readonly on the chipfield still allows deleting chips through the close button when the field is setClosable(true) and with the backspace button.
The expected behaviour would be to hide/gray out and disable the close buttons when the field is put to readonly (directly or through the binder). Also the backspace button should not allow to remove chips.

@thomasdewaelheyns thomasdewaelheyns changed the title Setting readonly still allows deleting chips when the field is setClosable(true) Setting readonly still allows deleting chips Feb 4, 2021
@javier-godoy javier-godoy added the bug Something isn't working label Feb 4, 2021
@javier-godoy javier-godoy added this to Inbox (needs triage) in Flowing Code Addons (legacy) via automation Feb 4, 2021
@javier-godoy javier-godoy self-assigned this Feb 4, 2021
@javier-godoy
Copy link
Member

Hello. Can you please post a small example? It seems to work as expected with

ChipField<String> chf = new ChipField<>("Read Only", "Mercury", "Venus", "Earth");
chf.setWidthFull();
chf.addSelectedItem("Mercury");
chf.addSelectedItem("Venus");
chf.setReadOnly(true);
chf.setClosable(true);

chipfield-readonly

@thomasdewaelheyns
Copy link
Author

thomasdewaelheyns commented Feb 4, 2021

Hi,

I don't have git installed on this laptop but with eclipse I made a simple example project that shows the behaviour I described. I think it may be more related to going from editable to readonly. I think I might have found an additional issue while making this example. If you add a new element (so one that does not exist) from the field, it will show up when you click the "Show values" button. When you remove that chip again, and press the button again, the value you created will be still in the values. The same behaviour can be observed in your Data Provider example.

To demonstrate my issues, I downloaded the master and added a new tab to the "ChipFieldDemoView". The example class is called "ReadOnlyExample" in test in the com.flowingcode.vaadin.addons.chipfield.readonly package. Please let me know if you need further input.
ChipFieldAddon_readonly.zip

@javier-godoy
Copy link
Member

Thanks. Your example reproduces the issue, I'll investigate.

@javier-godoy javier-godoy moved this from Inbox (needs triage) to To Do in Flowing Code Addons (legacy) Feb 4, 2021
@javier-godoy
Copy link
Member

When adding a new item, the data provider is not updated with the new item, thus findItemByLabel will not retrieve it (#35).
Additionally, setValue("Test") (called by Binder) causes the creation of a new chip that isn't registeres as an additional item with the component (#36). Then, when the component is in readonly mode, it will allow deletion of such "unknown" items.

@thomasdewaelheyns
Copy link
Author

Are these issues being followed up on? I saw on a separate branch work was started but the last commit was 16 days ago. I'm asking because we are coming up on a test-release and I will have to substitute out the chipfield for something else otherwise while I would prefer to stick with your addon.

@javier-godoy
Copy link
Member

Yes, and I want to thank you very much for reporting those. They helped us a lot for improving the component.

I had it in my backlog, but then I got other assignments and couldn't complete it. That branch fixes #35 and #36 which are the causes of this one. On the other hand I wasn't confident enough for a release, because the latest changes resulted in a very complicate internal logic (there are several actions, both client and server-side that result in chips being created or deleted). Then, I started with some integration tests using TestBench in order to verify there were no regressions. Would it be OK for you if we release it as an snapshot version while we wrap the changes?

@thomasdewaelheyns
Copy link
Author

thomasdewaelheyns commented Feb 25, 2021

Hey Javier,

No worries, I was not meaning to rush you. Please, take the time you need to finish making this the quality component I know it can be. Since this component is not yet used by us in anything in production I can test already a snapshot version and report any issues if I encounter any. I was just asking because the inability to delete chips was impeding on testing the general workflow.

@javier-godoy
Copy link
Member

javier-godoy commented Feb 25, 2021

@thomasdewaelheyns fixes were merged into 2.4.0-SNAPSHOT, which has been deployed to https://maven.flowingcode.com/snapshots

@javier-godoy javier-godoy added this to the 2.4.0 milestone Feb 25, 2021
@thomasdewaelheyns
Copy link
Author

@javier-godoy Thank you, I'll give it a go tomorrow and get back to you with my findings.

@thomasdewaelheyns
Copy link
Author

I tested the 2.4.0-SNAPSHOT quickly and so far all issues that I noticed seem resolved.

  • Changing read only state now actually locks and unlocks deleting of items correctly. On or more items can still disappear for a split second when clicking the close button or backspacing but they are correctly returned into the UI and they are not being deleted in the back-end
  • Chips can now correctly be deleted from the UI and they also are correctly removed from the back-end. Both for existing chips and newly created ones.
    Next week I'm letting our research team and application specialists lose on the application and let them test more scenarios.

@javier-godoy
Copy link
Member

javier-godoy commented Feb 26, 2021

Thanks for the confirmation. I'm closing this issue since the component now preserves its value in read-only mode. I'll open a separate issue about improving the visual aspect, because there are several indicators that suggest the user can interact with the component (close button, blue underline, hand cursor).

Feel free to report if your team finds some other issue, or whether this fix was not sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants