Commit 6b03abd
authored
feat: introduce WithDragAndDropUpload component (#2688)
### 🎯 Goal
Current `Channel.dragAndDropWindow` and
`Channel.optionalMessageInputProps` architecture which used to allow
drag&drop file upload by dropping files onto the message list (channel)
component suffers from a few pain points:
- duplicate `MessageInputContextProvider` initialization, see
[here](https://github.com/GetStream/stream-chat-react/blob/5fa6b0fc239a7d48032ae4c3d34e29969c52bd0c/src/components/Channel/Channel.tsx#L1479-L1484),
[here](https://github.com/GetStream/stream-chat-react/blob/5fa6b0fc239a7d48032ae4c3d34e29969c52bd0c/src/components/MessageInput/MessageInput.tsx#L137-L159)
and
[here](https://github.com/GetStream/stream-chat-react/blob/5fa6b0fc239a7d48032ae4c3d34e29969c52bd0c/src/components/MessageInput/DropzoneProvider.tsx#L47-L67)
([related
issue](https://getstream.slack.com/archives/C02R5UCGN6N/p1740392263047589))
- broken styling ([v2 vendor
folder](https://github.com/GetStream/stream-chat-css/tree/v5.8.0/src/v2/styles/vendor)
is missing [react-file-utils
styling](https://github.com/GetStream/stream-chat-css/blob/v5.8.0/src/vendor/react-file-utils.scss))
New solution allows dragging and uploading files both in "channel" and
in thread individually - which was previously impossible. The new
solution also reuses drag and drop styling which is used by default in
`MessageInputFlat` component (some minor adjustments from integrators
are needed - such as setting relative positioning on required parents).
#### Old API:
```tsx
<Channel dragAndDropWindow>
<Window>
<ChannelHeader />
<MessageList />
<AIStateIndicator />
<MessageInput focus />
</Window>
<Thread virtualized />
</Channel>
```
#### New API:
```tsx
<Channel>
<WithDragAndDropUpload className='str-chat__main-panel'>
<ChannelHeader/>
<MessageList />
<AIStateIndicator />
<MessageInput focus />
</WithDragAndDropUpload>
<WithDragAndDropUpload>
<Thread virtualized />
</WithDragAndDropUpload>
</Channel>
```
### Deprecations
#### Public
- `Channel.dragAndDropWindow` prop (will remove in v13)
- `Channel.optionalMessageInputProps` prop (will remove in v13)
#### Private
- `DropzoneProvider`
- `DropzoneInner`
- `ImageDropzone`
Note: This is not a direct fix of the issue I mentioned above (Slack
link), I believe the proper fix is to move away from this messy
architecture (by removing deprecated components and options which we'll
do in v13 once this PR is merged).
THIS PR RELIES ON [CSS
CHANGES](GetStream/stream-chat-css#329)
### 🎨 UI Changes
Before:

After:
1 parent 5fa6b0f commit 6b03abd
File tree
6 files changed
+228
-109
lines changed- src
- components
- Channel
- MessageInput
- context
6 files changed
+228
-109
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
| |||
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
249 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
31 | | - | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
36 | 33 | | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
| |||
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
51 | | - | |
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
57 | 53 | | |
58 | | - | |
59 | 54 | | |
60 | 55 | | |
61 | 56 | | |
| |||
71 | 66 | | |
72 | 67 | | |
73 | 68 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 69 | + | |
| 70 | + | |
79 | 71 | | |
80 | 72 | | |
81 | 73 | | |
| |||
96 | 88 | | |
97 | 89 | | |
98 | 90 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | 91 | | |
117 | 92 | | |
118 | 93 | | |
| |||
156 | 131 | | |
157 | 132 | | |
158 | 133 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
181 | 142 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
189 | 155 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | 156 | | |
195 | | - | |
196 | | - | |
| 157 | + | |
| 158 | + | |
197 | 159 | | |
198 | | - | |
199 | | - | |
| 160 | + | |
200 | 161 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
210 | 182 | | |
211 | | - | |
212 | | - | |
213 | | - | |
| 183 | + | |
| 184 | + | |
214 | 185 | | |
215 | | - | |
216 | | - | |
217 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
218 | 191 | | |
219 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
220 | 196 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
242 | 203 | | |
243 | | - | |
| 204 | + | |
244 | 205 | | |
245 | 206 | | |
0 commit comments