Commit Graph

38 Commits

Author SHA1 Message Date
Evy Kassirer
464b7f4540 compose_state: Rename private_message_recipient to clarify it stores emails.
This will add clarity as we move towards using ids more and emails
less.
2025-05-16 10:51:29 -07:00
Evy Kassirer
f648a7f515 compose_actions: Update and sync type for on_narrow. 2025-05-07 09:31:19 -07:00
Lauryn Menard
d7873fbc11 compose-actions: Set topic earlier if specified in start opts.
When on_compose_select_recipient_update is called when we start
the compose box actions, then it subsequently calls
compose_recipient.update_on_recipient_change.

If there is a specified topic in the opts for the compose box,
then that should be set for various functions that are called
in update_on_recipient_change.

compose_recipient.update_topic_displayed_text is called later for
all cases, direct messages and empty topics, which will update the
compose_state.topic again.
2025-03-27 12:52:07 -07:00
Aman Agrawal
4fbf91c135 compose: Fix buggy tooltip on validation.
Compose send tooltip was not correctly displayed when the compose
box was in an invalid state.

We significanlty improve the logic for displaying the tooltip here
to provide a more robust experience to the user.
2025-03-17 11:35:56 -07:00
Apoorva Pendse
54fd02b173 compose_tooltip: Remove delay for invalid messages.
Does what 714def080f
was trying to do without the side effects.
Fixes: 714def080f
2025-03-11 09:41:22 -07:00
Aman Agrawal
834e69d17c compose_actions: Fix send button disabled without any error.
Reproducer:
* Upload a file.
* Close compose box before upload is finished.
* Open compose box.

Send message button is disabled without any error in this state.
Fixed by resetting the send button state when compose box is closed.
2025-03-10 21:53:10 -07:00
Karl Stolley
a3a43c2f8b compose: Handle fading with general chat.
This commit also attempts to fix a bug, present in main, where a
draft restored directly to the compose box loses its original topic
upon switching to other topic narrows.

Co-authored-by: Prakhar Pratyush <prakhar@zulip.com>
2025-02-26 13:59:03 -08:00
Karl Stolley
1bc53831c7 compose: Conditionally render placeholder for general chat. 2025-02-26 13:59:02 -08:00
Karl Stolley
cae48d3faa compose: Rename placeholder update function for clarity. 2025-02-26 13:59:02 -08:00
opmkumar
1e99745023 todo_list: Add option for modal to create todo-lists.
A button has been introduced to launch a modal
for creating todo-lists directly from the compose box.

The modal features a form that, upon submission,
generates a message using the `/todo` syntax and the data
inputted in the form. Subsequently, the content of the compose box
is set to this message, which the user can then send.

This modal closely parallels the UI for adding a poll; therefore,
the poll and todo code has been shifted to a newly created
file named `widget_modal.ts`, and `poll_modal.ts` is now deprecated.

Co-authored-by: Sujal Shah <sujalshah28092004@gmail.com>

Fixes #29779.
2025-02-14 14:57:24 -08:00
Vector73
7440444a90 saved_snippets: Move initialization directly to ui_init.ts.
Defer saved snippets dropdown creation until the compose box
is opened for better performance.

Fixes #31831.
2025-02-14 11:51:40 -08:00
Vector73
cb6f0fd63c realm: Add setting to notify user on DMing guest.
Added `enable_guest_user_dm_warning` setting to decide whether
clients should show a warning when a user is composing to a guest
user in the organization.

Fixes #30078.

Co-authored-by: adnan-td <generaladnan139@gmail.com>
2025-02-06 12:15:41 -08:00
Karl Stolley
8feaa5e6e8 compose: Initialize scrolling buttons only when needed. 2025-01-14 15:52:02 -08:00
Maneesh Shukla
e856294da6 compose: Open the compose box with channel picker.
This commit changes the code in such a way that the
"Start new conversation" button open the compose box with the channel
picker open, as we do when no channels is selected.

Fixes #28410.

Co-authored-by: Kunal Sharma <v.shm.kunal@gmail.com>
2024-12-16 10:50:12 -08:00
Emil Grehn
83a121c7e4 compose_recipient: Rename funciton open_compose_recipient_dropdown.
Renames the function 'open_compose_recipient_dropdown'
to 'toggle_compose_recipient_dropdown'
to better describe what it actually does.
2024-12-07 22:00:08 -08:00
opmkumar
88727862b4 compose: Refactor functions for handling max length limits.
Refactors `check_overflow_text` and `validate_message_length` functions.
This commit ensures that there won't be any change in the existing UI
of the compose box with the refactoring of the above functions.
2024-12-04 11:44:51 -08:00
Anders Kaseorg
ec3177c834 web: Add explicit extensions to imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00
Anders Kaseorg
52e59a9605 web: Add setters for rewired variables.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-08 12:38:14 -08:00
opmkumar
1ddc1d2d12 search: Refactor how close buttons are handled.
We refactor the following inputs to use a `placeholder-shown` CSS selector to
show/hide the close button, rather than custom JS logic:
- Filter topics field in the left sidebar
- Filter direct messages field under direct messages
- Stream message topic
2024-09-23 16:04:10 -07:00
Aman Agrawal
970dd30f96 compose: Fix restoring big drafts freezes the app.
We are using `.val` to set compose box content which is very fast vs
`setFieldText` which is very slow due to it doing a lot of
forced repaints. The major downside of using `val` here is that
user will not able to perform `undo` operation on this which doesn't
seem something user would want to do here.

Note that this effects compose content restored from drafts,
scheduled messages and on reload.
2024-08-13 07:53:30 -07:00
Prakhar Pratyush
df7ed437c2 compose: Show banner to explain interleaved view messages fading.
In an interleaved view when composing a message we fade messages
which the user is not replying to, to reduce the chance they send
a message to a recipient they didn't intend to.
Also, it reduces the visual/cognitive processing required
to figure out where their message is going to go.

But, it's not necessarily clear to users that what the
fading means, so this commit adds a one-time compose banner
to explain what's going on the first time this comes up.

Fixes part of #29076.
2024-07-16 13:52:30 -07:00
Prakhar Pratyush
35380b095f compose: Show banner to explain non interleaved view messages fading.
In a non interleaved view when composing a message to another
conversation we fade messages which the user is not replying to,
to reduce the chance they send a message to a recipient they didn't
intend to. Also, it reduces the visual/cognitive processing required
to figure out where their message is going to go.

But, it's not necessarily clear to users that what the
fading means, so this commit adds a one-time compose banner
to explain what's going on the first time this comes up.

Fixes part of #29076.
2024-07-16 13:52:29 -07:00
Vector73
6098c2cebe settings: Add two realm settings to restrict direct messages.
Fixes #24467.
2024-07-08 19:34:17 -07:00
N-Shar-ma
9bc1eb4bb9 compose: Allow 3-way compose box resizing with new fixed expanded state.
Apart from the normal (collapsed) and full screen sizes, a new expanded
state with the same size as the maximum a normal compose box can stretch
to when full (40% of the screen height) is now available. Now a user can
expand the compose box without it covering the full screen with a click.
The vertical resize icon in the bottom right corner of the compose box
is rendered useless so has been removed.

All three states can be cycled through by clicking the compose resize
button in the order: collapsed -> 40% of the screen -> full screen. When
a message naturally causes the compose box in its normal state to expand
up to 40% of the screen, clicking the resize button will take it to full
screen state.

Fixes: #29966.
2024-06-26 16:36:52 -07:00
N-Shar-ma
b432b269ee refactor: Make compose size related variables & functions more specific.
We divide functionality into that for "full_size" and "expanded", which
are identical for now.

This is a prep commit for adding an intermediate expanded screen size.
2024-06-26 16:36:52 -07:00
N-Shar-ma
906a9ca8f2 compose: Rework alignment of upper elements, and redesign close icon.
We now right align recipient input (even at very narrow widths) and
banners to the textbox, and move the close button to the absolute top
right corner of the compose box, updating the icon to be slimmer, bigger
and purplish, and adding a background highlight on hover.

This involved refactoring the send control area width into a responsive
css variable, and simplifying the html structure of the compose box.

Fixes: #28792.
2024-06-18 15:51:51 -07:00
evykassirer
346dc7d79d compose: Auto-close unchanged auto-opened drafts on narrow change.
Fixes #30104.
2024-06-07 10:38:20 -07:00
Anders Kaseorg
468da9ed23 compose_actions: Fix TypeScript noUncheckedIndexedAccess errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-30 15:54:48 -07:00
Anders Kaseorg
507eb4913c tsconfig: Enable exactOptionalPropertyTypes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-16 08:58:20 -07:00
Anders Kaseorg
49e1c919c3 drafts: Convert .data("draft-id") to a module variable.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-07 12:57:14 -07:00
evykassirer
2c2dfa4c3d draft: Only auto-restore drafts edited since adding the feature. 2024-04-20 13:27:25 -07:00
evykassirer
45a81650f4 compose: Add option to not restore drafts, to avoid overwriting.
This could happen e.g. when quote-replying a message,
because we open the composebox before adding the quote
reply content. We need to make sure that we don't restore
a draft when opening the composebox, because otherwise
that draft will be replaced with the quote reply.
2024-04-20 13:27:25 -07:00
evykassirer
3ef4e80dff compose: Add button to save draft and start a new message. 2024-04-20 13:27:24 -07:00
evykassirer
fd4246def5 drafts: Append a space to draft when restoring it.
If a user starts typing before they see that a draft was restored,
this makes that experience a little smoother by adding some
separation between the old draft and the new text.
2024-04-20 12:31:51 -07:00
Riken Shah
d48de6da08 compose: Restore the last draft when compose box is opened.
Now when the user opens a narrow that has a draft saved for
that particular conversation, the draft will automatically
be restored in the compose box. This will make it easy to
return to a draft after clicking away, and also will make
it less confusing when people close the compose box by
accident. Note that this only restores the draft when
there is a full recipient specified (stream and topic,
or at least one PM recipient).

Fixes part of #18555.
Fixes #11218 and #17396.
2024-04-20 12:31:51 -07:00
N-Shar-ma
a7719184ad compose: Refactor code to combine 2 same if condition blocks into one.
The blocks were originally separated by some code for seemingly no
reason, so now the 2nd block is brought up and combined into the first.
An old irrelevant comment is also removed.
2024-04-11 16:34:33 -07:00
N-Shar-ma
94dc5723c6 compose: Scroll cursor at message's end into view when restoring draft.
When a long message is restored from a draft (or scheduled messages),
its end, and the cursor placed there, used to be out of view, giving the
impression that the message was not focused, when it actually was.

This is fixed by always scrolling the cursor into view.
2024-04-11 16:34:33 -07:00
evykassirer
d6f4424102 compose_actions: Convert module to typescript. 2024-04-04 16:34:42 -07:00