mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Improve mentions keyboard accessibility (#10173)
* Improve keyboard accessibility * Add check for up down keys * Add newline check for triggering * Allow keyboard insertion of users * Clear positional node errors on safari * Add a little sanity check to please automated code checkers * Use active instead of dashed Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import logger from '../logger';
|
||||
import { userName } from '../utils/user-name';
|
||||
import { uniq } from 'lodash';
|
||||
import env from '../env';
|
||||
import validateUUID from 'uuid-validate';
|
||||
|
||||
export class ActivityService extends ItemsService {
|
||||
notificationsService: NotificationsService;
|
||||
@@ -66,10 +67,13 @@ export class ActivityService extends ItemsService {
|
||||
let comment = data.comment;
|
||||
|
||||
for (const mention of mentions) {
|
||||
comment = comment.replace(mention, userPreviews[mention.substring(1)] ?? '@Unknown User');
|
||||
const uuid = mention.substring(1);
|
||||
// We only match on UUIDs in the first place. This is just an extra sanity check
|
||||
if (validateUUID(uuid) === false) continue;
|
||||
comment = comment.replace(new RegExp(mention, 'gm'), userPreviews[uuid] ?? '@Unknown User');
|
||||
}
|
||||
|
||||
comment = `> ${comment}`;
|
||||
comment = `> ${comment.replace(/\n+/gm, '\n> ')}`;
|
||||
|
||||
const message = `
|
||||
Hello ${userName(user)},
|
||||
|
||||
Reference in New Issue
Block a user