From f387ef8a27812cf53d357ce78092c190195e25a5 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 18 Dec 2020 19:23:08 +0200 Subject: [PATCH] Fix input field label selector Fix clearing input by selection in new media popup --- src/components/popups/newMedia.ts | 2 +- src/lib/appManagers/appMessagesManager.ts | 1 + src/scss/partials/_input.scss | 10 +++++----- src/scss/partials/popups/_mediaAttacher.scss | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/popups/newMedia.ts b/src/components/popups/newMedia.ts index 9c782a7d..ff750069 100644 --- a/src/components/popups/newMedia.ts +++ b/src/components/popups/newMedia.ts @@ -110,7 +110,7 @@ export default class PopupNewMedia extends PopupElement { private onKeyDown = (e: KeyboardEvent) => { const target = e.target as HTMLElement; - if(target.tagName != 'INPUT') { + if(target !== this.input) { this.input.focus(); placeCaretAtEnd(this.input); } diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 2d34d0a9..3678049a 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -248,6 +248,7 @@ export class AppMessagesManager { if(removeUnread && dialog.unread_count) dialog.unread_count -= removeUnread; + dialog.unread_count = Math.max(0, dialog.unread_count); dialogs.push(dialog); appStateManager.setPeer(dialog.peerId, appPeersManager.getPeer(dialog.peerId)); diff --git a/src/scss/partials/_input.scss b/src/scss/partials/_input.scss index 3dc9e2bd..83763346 100644 --- a/src/scss/partials/_input.scss +++ b/src/scss/partials/_input.scss @@ -95,7 +95,7 @@ &.error { border-color: $color-error; - & + label { + & ~ label { color: $color-error!important; } } @@ -103,7 +103,7 @@ &.valid { border-color: #26962F; - & + label { + & ~ label { color: #26962F !important; } } @@ -119,11 +119,11 @@ border-color: $button-primary-background; } - &:focus + label { + &:focus ~ label { color: $button-primary-background; } - &:focus + label, &:valid + label, &:not(:empty) + label, &:disabled + label { + &:focus ~ label, &:valid ~ label, &:not(:empty) ~ label, &:disabled ~ label { top: -.5rem; transform: none; padding: 0 5px; @@ -217,7 +217,7 @@ input:focus, button:focus { background-color: transparent; border-color: $button-primary-background; - & + .tgico { + & ~ .tgico { color: $button-primary-background; opacity: 1; } diff --git a/src/scss/partials/popups/_mediaAttacher.scss b/src/scss/partials/popups/_mediaAttacher.scss index 395d0db8..a5367749 100644 --- a/src/scss/partials/popups/_mediaAttacher.scss +++ b/src/scss/partials/popups/_mediaAttacher.scss @@ -141,7 +141,7 @@ font-size: 1rem; border-radius: $border-radius-medium; - &:not(:focus):empty + label { + &:not(:focus):empty ~ label { opacity: 0; } }