Skip to content

Commit

Permalink
Automatically tag user in message when clicking on dot
Browse files Browse the repository at this point in the history
  • Loading branch information
Liototo committed May 24, 2024
1 parent 2999401 commit 4de066a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/collaboration/src/activitydotplot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ export const ActivityDotPlot: React.FC<DotPlotProps> = ({tracker, app, chatPanel

const handleDotClick = (data: any) => {

const username = data.points[0].text.split(' on ')[0];

app.shell.activateById('jp-chat-panel');

const chatbox = chatPanel.widgets.find(widget => widget.id === 'jp-chatbox') as Chatbox | null;

if (chatbox) {

chatbox.show();
chatbox.focusOnWritingField();
chatbox.focusOnWritingField(username);

}

Expand Down
8 changes: 7 additions & 1 deletion packages/collaboration/src/chatbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ export class Chatbox extends ReactWidget {
this.addClass('jp-Chat-Panel')
}

focusOnWritingField() {
focusOnWritingField(username?: string) {

const writingField = this.node?.querySelector('.jp-Chat-WritableField') as HTMLTextAreaElement | null;

if (writingField) {

writingField.focus();

if (username) {

writingField.value = `@${username} `;

}

}

}
Expand Down

0 comments on commit 4de066a

Please sign in to comment.