From c041d221bf9af845a2f74d436f9d25942bc05102 Mon Sep 17 00:00:00 2001 From: sreehari jayaraj Date: Fri, 22 Sep 2023 15:26:12 +0000 Subject: [PATCH] feat: scroll to end on overflow --- .../components/workspace/InviteSection.vue | 98 +++++++++++-------- 1 file changed, 59 insertions(+), 39 deletions(-) diff --git a/packages/nc-gui/components/workspace/InviteSection.vue b/packages/nc-gui/components/workspace/InviteSection.vue index 7b9612b059..040e825c06 100644 --- a/packages/nc-gui/components/workspace/InviteSection.vue +++ b/packages/nc-gui/components/workspace/InviteSection.vue @@ -7,6 +7,10 @@ const inviteData = reactive({ roles: WorkspaceUserRoles.VIEWER, }) +const focusRef = ref() + +const divRef = ref() + const workspaceStore = useWorkspace() const { inviteCollaborator: _inviteCollaborator } = workspaceStore @@ -22,6 +26,18 @@ watch(inviteData, (newVal) => { } }) +const scrollToEnd = () => { + if (divRef.value) { + const maxScrollLeft = divRef.value.scrollWidth - divRef.value.clientWidth + divRef.value.scrollLeft = maxScrollLeft + } +} + +const handleEnter = () => { + inviteData.email += ',' + scrollToEnd() +} + const inviteCollaborator = async () => { try { let inviteEmails = '' @@ -31,11 +47,10 @@ const inviteCollaborator = async () => { await _inviteCollaborator(inviteEmails, inviteData.roles) message.success('Invitation sent successfully') - } catch (e: any) { - message.error(await extractSdkResponseErrorMsg(e)) - } finally { inviteData.email = '' emailBadges.value = [] + } catch (e: any) { + message.error(await extractSdkResponseErrorMsg(e)) } } // allow only lower roles to be assigned @@ -58,50 +73,55 @@ onMounted(async () => {