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

Use new dropzone/input component in limel-file #2820

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

civing
Copy link
Contributor

@civing civing commented Mar 4, 2024

Makes use of the new limel-file-dropzone and limel-file-input component in limel-file. All the other functionality of limel-file should be unchanged.

Fixes https://github.com/Lundalogik/crm-feature/issues/3941

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

Copy link

github-actions bot commented Mar 4, 2024

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-2820/

@civing civing requested a review from a team as a code owner March 4, 2024 13:09
@civing civing force-pushed the file-input branch 2 times, most recently from b9a1c42 to cce1708 Compare March 4, 2024 14:29
@civing civing force-pushed the refactor-file-for-new-dropzone branch from 7a7f07b to c154dbf Compare March 4, 2024 14:31
@civing civing changed the title refactor(file): use new dropzone/input component Use new dropzone/input component in limel-file Mar 4, 2024
@LawrenceBorst LawrenceBorst self-requested a review March 5, 2024 14:35
Copy link
Contributor

@LawrenceBorst LawrenceBorst left a comment

Choose a reason for hiding this comment

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

Almost ready. I'll add fixups for some of the comments and you can decide if you want to keep them 😛

src/components/file/file.tsx Outdated Show resolved Hide resolved
src/components/file/file.tsx Show resolved Hide resolved
src/components/file/file.tsx Outdated Show resolved Hide resolved
src/components/file/file.tsx Show resolved Hide resolved
@LawrenceBorst

This comment was marked as off-topic.

@LawrenceBorst LawrenceBorst force-pushed the refactor-file-for-new-dropzone branch from 7b9b5d1 to e9e0e5e Compare March 6, 2024 13:15
@civing civing force-pushed the file-input branch 2 times, most recently from eb9a02a to f24a32a Compare March 6, 2024 14:00
@civing civing force-pushed the refactor-file-for-new-dropzone branch from e9e0e5e to 984ad4a Compare March 6, 2024 15:08
src/components/file/file.tsx Outdated Show resolved Hide resolved
Base automatically changed from file-input to main March 7, 2024 16:52
@civing civing force-pushed the refactor-file-for-new-dropzone branch 3 times, most recently from 14df2bb to 79e0db9 Compare March 9, 2024 14:55
@civing civing enabled auto-merge (rebase) March 9, 2024 14:57
@adrianschmidt adrianschmidt dismissed their stale review March 11, 2024 15:39

Requested changes no longer applies

Comment on lines 103 to 105
event.stopPropagation();
event.preventDefault();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this expected behaviour? If we have the file-input component disabled that means that any click wont open the native file select dialog but will still propagate the click event.

As it was previously any click event were stopped, so if you had something like this the chip would not open a link

<limel-file-input disabled={true}>
  <limel-chip text="cat.jpg", link={href: "/cat.jpg"} />
</limel-file-input>

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say that expected behaviour for this PR is that the component keeps working as it did before… isn't this supposed to just be a refactor?

Copy link
Contributor Author

@civing civing Mar 12, 2024

Choose a reason for hiding this comment

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

Yeah, the implications discussed are in <limel-file-input>. Or what do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, ok, I didn't notice that this wasn't limel-file 😄

I'm not sure, since I haven't yet gathered enough context, but since this component is meant to wrap some other component, I think the consumer needs to be responsible for controlling the behaviour of the wrapped component. So if they don't want anything to be clickable inside limel-file-input when limel-file-input is disabled, they have to disable the component inside it themselves. If we block all clicks, we make it impossible for the consumer to implement at more nuanced behaviour, like being able to click on existing chips, but not add new files, for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sum up of discussion we had in a huddle:

We'll pause this refactoring for now, because we don't use limel-file in the activities composer, so we don't need this refactoring right now. Then we will look into possibly changing the UI a bit. We would like there to be a simple button for browsing files to upload, rather than the currently quite weird interaction where you focus a text-field to get the file-dialog. With keyboard navigation, you currently have to tab to the input field, and then press enter to get the file-dialog. That doesn't seem very intuitive, and is probably really bad for accessibility…

Comment on lines 128 to 131
<limel-file-input
accept={this.accept}
disabled={this.disabled || this.readonly || !!this.value}
>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In one iteration of this PR I wrapped the <limel-chip-set> inside a <limel-file-input> only if we expected it to be clickable (no file selected). I changed it into this but just now realised we need this change a85e952 to make it work.

It's maybe a bit strange to have it like this if we would like to make the component work with multiple files? Maybe that's a headache for another time ... ?

This comment is also relevant in this context https://github.com/Lundalogik/lime-elements/pull/2820/files#r1521124280

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe that's a headache for another time ... ?

Yes, for another time :)

LawrenceBorst
LawrenceBorst previously approved these changes Mar 13, 2024
Copy link
Contributor

@LawrenceBorst LawrenceBorst left a comment

Choose a reason for hiding this comment

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

Tested this last night. Everything works as expected. Code looks good, had some comments but they don't really concern the changes here :)

@civing
Copy link
Contributor Author

civing commented Mar 13, 2024

I've been thinking a lot about the chipset that serves as both clickable chips but also as a file input handler. I would like to move the file input handling to a new button and let the chipset be a chipset and nothing else.

civing added 2 commits March 14, 2024 10:53
Makes use of the new `limel-file-dropzone` and `limel-file-input`
component in `limel-file`.
Remove the `MDCTextField` element since it doesn't really add any value
at all. Following this change the invalid visualization is less buggy
and shows up imidiatly following an invalid state.
@civing civing force-pushed the refactor-file-for-new-dropzone branch from fb80bbb to 3b61080 Compare March 14, 2024 09:53
@civing civing merged commit 227b0da into main Mar 14, 2024
11 checks passed
@civing civing deleted the refactor-file-for-new-dropzone branch March 14, 2024 09:56
@lime-opensource
Copy link
Collaborator

🎉 This PR is included in version 37.11.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants