From 752cc628ff65eb7be31b58c5d8b4d2a7dfd17b8f Mon Sep 17 00:00:00 2001 From: Demirci Date: Wed, 13 Nov 2024 18:51:36 +0300 Subject: [PATCH] fix(core/drawer|inputgroup): fixed drawer display issue --- .../core/src/components/drawer/drawer.scss | 6 +++-- .../core/src/components/drawer/drawer.tsx | 11 +++----- .../components/input-group/input-group.tsx | 25 ++++++++----------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/packages/core/src/components/drawer/drawer.scss b/packages/core/src/components/drawer/drawer.scss index f0d2eff2cb..60db35068f 100644 --- a/packages/core/src/components/drawer/drawer.scss +++ b/packages/core/src/components/drawer/drawer.scss @@ -20,17 +20,19 @@ visibility: hidden; display: flex; - position: absolute; + position: fixed; flex-flow: column nowrap; justify-content: flex-start; align-items: center; + transform: translateX(16rem); + opacity: 0; max-height: 100vh; min-height: $large-space; background-color: var(--theme-color-1); border-radius: $default-border-radius; - transition: all var(--theme-medium-time) ease-out; + transition: transform var(--theme-medium-time) ease-out; .toggle { z-index: 100; diff --git a/packages/core/src/components/drawer/drawer.tsx b/packages/core/src/components/drawer/drawer.tsx index d5941bd4a6..1e7342286c 100644 --- a/packages/core/src/components/drawer/drawer.tsx +++ b/packages/core/src/components/drawer/drawer.tsx @@ -70,7 +70,8 @@ export class Drawer { private divElement?: HTMLElement; @Watch('show') - onShowChanged(newValue: boolean) { + onShowChanged(newValue: boolean, oldValue?:boolean) { + if(newValue === !!oldValue) return; this.show = newValue !== undefined ? newValue : !this.show; this.toggleDrawer(this.show); } @@ -127,9 +128,6 @@ export class Drawer { translateX: [0, '16rem'], opacity: [1, 0], easing: 'easeInSine', - complete: () => { - el.classList.add('d-none'); - }, }); } @@ -140,9 +138,6 @@ export class Drawer { translateX: ['16rem', 0], opacity: [0, 1], easing: 'easeOutSine', - begin: () => { - el.classList.remove('d-none'); - }, }); } @@ -157,7 +152,7 @@ export class Drawer { 'drawer-container': true, toggle: this.show, 'full-height': this.fullHeight, - 'd-none': true, + }} style={{ width: this.width === 'auto' ? this.width : `${this.width}rem`, diff --git a/packages/core/src/components/input-group/input-group.tsx b/packages/core/src/components/input-group/input-group.tsx index 57cb199304..5a70e20b55 100644 --- a/packages/core/src/components/input-group/input-group.tsx +++ b/packages/core/src/components/input-group/input-group.tsx @@ -22,6 +22,9 @@ export class InputGroup { @State() inputPaddingLeft = 0; @State() inputPaddingRight = 0; + + startSlotRef: HTMLElement; + endSlotRef: HTMLElement; private get inputElement() { return this.hostElement.querySelector('input') as HTMLInputElement; @@ -61,6 +64,7 @@ export class InputGroup { }); } + componentDidRender() { this.prepareInputElement(); } @@ -100,12 +104,7 @@ export class InputGroup { } private startSlotChanged() { - const slot = this.hostElement.shadowRoot.querySelector( - 'slot[name="input-start"]' - ); - - setTimeout(() => { - const startPadding = this.getChildrenWidth(slot); + const startPadding = this.getChildrenWidth(this.startSlotRef); if (startPadding !== 0) { this.inputPaddingLeft = 11 + startPadding; @@ -130,20 +129,16 @@ export class InputGroup { this.inputElement.style.backgroundPosition = `left ${left}px center`; this.inputPaddingLeft += 26; } - }); + } private endSlotChanged() { - const slot = this.hostElement.shadowRoot.querySelector( - 'slot[name="input-end"]' - ); + this.inputPaddingRight = 15 + this.getChildrenWidth(this.endSlotRef); - setTimeout(() => { - this.inputPaddingRight = 15 + this.getChildrenWidth(slot); - }); } private getChildrenWidth(slotElement: Element) { + if (!slotElement) { return 0; } @@ -166,11 +161,11 @@ export class InputGroup { return (
- + this.startSlotRef = el} name="input-start">
- + this.endSlotRef = el} name="input-end">
);