Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core/drawer|inputgroup): fixed drawer display issue #1561

Merged
merged 36 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
87e0a0c
fix(core/drawer|inputgroup): fixed drawer display issue
Nov 13, 2024
3e34ba2
Merge branch 'main' into fix/1551-drawer-style-issue
danielleroux Dec 2, 2024
eaf1bd3
Merge remote-tracking branch 'refs/remotes/origin/main' into fix/1551โ€ฆ
matthiashader Dec 17, 2024
9df7db1
fix: toggle behavior, add vrt, deprecate input-group
matthiashader Dec 18, 2024
3b933cf
Merge branch 'refs/heads/main' into fix/1551-drawer-style-issue
matthiashader Dec 18, 2024
df35737
fix: test push
matthiashader Dec 18, 2024
8ff107e
Revert "fix: test push"
matthiashader Dec 18, 2024
6b68edc
fix: component doc
matthiashader Dec 18, 2024
26dcf15
fix: revert changes, remove bootstrap dep
matthiashader Dec 18, 2024
d454797
Merge branch 'refs/heads/main' into fix/1551-drawer-style-issue
matthiashader Dec 18, 2024
ebf082b
fix: storybook, behavior
matthiashader Dec 19, 2024
1203e18
fix: review comments
matthiashader Dec 19, 2024
43b14f2
fix: adapt selector
matthiashader Dec 19, 2024
98764ce
fix: review comments
matthiashader Jan 8, 2025
4161e6f
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Jan 8, 2025
be42e9f
update: updated input-group deprecated version
Jan 10, 2025
bb87354
fix: update component-doc
matthiashader Jan 15, 2025
3b6865c
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Jan 15, 2025
b9814b2
fix: update vrt for ubuntu noble
matthiashader Jan 15, 2025
04a4715
fix: unit test inside the container
matthiashader Jan 16, 2025
9387340
feat: adapt animation behavior
matthiashader Jan 20, 2025
33fe6b7
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Jan 20, 2025
702b674
fix: reveal content on fully expand
matthiashader Jan 27, 2025
b6d6607
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Jan 27, 2025
b1fba91
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Jan 29, 2025
51f833f
fix: remove content hidding at the beginning
matthiashader Feb 11, 2025
dab3c7b
Merge remote-tracking branch 'ridvandmrc/fix/1551-drawer-style-issue'โ€ฆ
matthiashader Feb 11, 2025
ed479c6
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Feb 11, 2025
7cd627c
Update packages/core/src/components/drawer/drawer.tsx
matthiashader Feb 17, 2025
7c1bdd3
Merge branch 'main' into fix/1551-drawer-style-issue
matthiashader Feb 17, 2025
3e67541
fix: merge main and resolve merge conflicts
matthiashader Feb 24, 2025
56dd11b
fix: lint
matthiashader Feb 24, 2025
79cdc6a
fix: review comments
matthiashader Feb 24, 2025
17d25ab
fix: revert change
matthiashader Feb 24, 2025
3ac7d30
docs: add changeset
nuke-ellington Feb 28, 2025
fb205fb
Merge branch 'main' into fix/1551-drawer-style-issue
nuke-ellington Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-waves-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siemens/ix': patch
---

Update slot references for **ix-input-group**.
5 changes: 5 additions & 0 deletions .changeset/tame-deers-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siemens/ix': patch
---

**ix-drawer**: Allow nested content to calculate it's layout properly by setting drawer width explicitly.
8 changes: 7 additions & 1 deletion packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10879,11 +10879,17 @@
"overview": "",
"usage": {},
"docs": "",
"docsTags": [],
"docsTags": [
{
"name": "deprecated",
"text": "since 3.0.0. Will be removed with 4.0.0.\nUse the 'ix-input' component instead"
}
],
"encapsulation": "shadow",
"dependents": [],
"dependencies": [],
"dependencyGraph": {},
"deprecation": "since 3.0.0. Will be removed with 4.0.0.\nUse the 'ix-input' component instead",
"props": [],
"methods": [],
"events": [],
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,10 @@ export namespace Components {
*/
"warningText"?: string;
}
/**
* @deprecated since 3.0.0. Will be removed with 4.0.0.
* Use the 'ix-input' component instead
*/
interface IxInputGroup {
}
/**
Expand Down Expand Up @@ -4220,6 +4224,10 @@ declare global {
prototype: HTMLIxInputElement;
new (): HTMLIxInputElement;
};
/**
* @deprecated since 3.0.0. Will be removed with 4.0.0.
* Use the 'ix-input' component instead
*/
interface HTMLIxInputGroupElement extends Components.IxInputGroup, HTMLStencilElement {
}
var HTMLIxInputGroupElement: {
Expand Down Expand Up @@ -6887,6 +6895,10 @@ declare namespace LocalJSX {
*/
"warningText"?: string;
}
/**
* @deprecated since 3.0.0. Will be removed with 4.0.0.
* Use the 'ix-input' component instead
*/
interface IxInputGroup {
}
/**
Expand Down Expand Up @@ -8880,6 +8892,10 @@ declare module "@stencil/core" {
* @form-ready 2.6.0
*/
"ix-input": LocalJSX.IxInput & JSXBase.HTMLAttributes<HTMLIxInputElement>;
/**
* @deprecated since 3.0.0. Will be removed with 4.0.0.
* Use the 'ix-input' component instead
*/
"ix-input-group": LocalJSX.IxInputGroup & JSXBase.HTMLAttributes<HTMLIxInputGroupElement>;
/**
* @since 1.6.0
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/components/drawer/drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
right: 0;
@include box-shadow(3);

display: flex;
display: block;
position: absolute;
flex-flow: column nowrap;
justify-content: flex-start;
align-items: center;
opacity: 0;

max-height: 100vh;
min-height: $large-space;
Expand Down Expand Up @@ -52,10 +52,13 @@
.content {
position: relative;
flex: 1;
flex-grow: 1;
order: 2;
height: 100%;
width: 100%;
overflow-y: auto;
}
}

:host(.display-none) {
display: none;
}
129 changes: 79 additions & 50 deletions packages/core/src/components/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Host,
Method,
Prop,
State,
Watch,
} from '@stencil/core';
import anime from 'animejs';
Expand Down Expand Up @@ -71,6 +72,8 @@ export class Drawer {
private callback = this.clickedOutside.bind(this);
private divElement?: HTMLElement;

@State() showContent = true;

@Watch('show')
onShowChanged(newValue: boolean, oldValue?: boolean) {
if (newValue === oldValue) {
Expand All @@ -96,14 +99,12 @@ export class Drawer {
}

this.show = true;

if (!this.toggle) {
if (!this.toggle && this.divElement) {
this.slideInRight(this.divElement);
setTimeout(() => {
window.addEventListener('mousedown', this.callback);
}, Drawer.duration);
}

setTimeout(() => {
window.addEventListener('mousedown', this.callback);
}, 300);
} else {
const { defaultPrevented } = this.drawerClose.emit();

Expand All @@ -113,7 +114,7 @@ export class Drawer {

this.show = false;

if (this.toggle) {
if (this.toggle && this.divElement) {
this.slideOutRight(this.divElement);
}

Expand Down Expand Up @@ -147,34 +148,45 @@ export class Drawer {
}
}

private slideOutRight(el?: HTMLElement) {
if (el) {
anime({
targets: el,
duration: Drawer.duration,
translateX: [0, '16rem'],
opacity: [1, 0],
easing: 'easeInSine',
complete: () => {
el.classList.add('d-none');
},
});
}
private getConstrainedWidth(width: number) {
return Math.min(Math.max(width, this.minWidth), this.maxWidth);
}

private slideInRight(el?: HTMLElement) {
if (el) {
anime({
targets: el,
duration: Drawer.duration,
translateX: ['16rem', 0],
opacity: [0, 1],
easing: 'easeOutSine',
begin: () => {
el.classList.remove('d-none');
},
});
}
private slideOutRight(el: HTMLElement) {
const initialWidth = `${this.getConstrainedWidth(
this.width === 'auto' ? this.minWidth : this.width
)}rem`;

anime({
targets: el,
duration: Drawer.duration,
width: [initialWidth, 0],
opacity: [1, 0],
easing: 'easeInSine',
complete: () => {
el.classList.add('display-none');
},
});
}

private slideInRight(el: HTMLElement) {
const targetWidth = `${this.getConstrainedWidth(
this.width === 'auto' ? this.minWidth : this.width
)}rem`;

anime({
targets: el,
duration: Drawer.duration,
width: [0, targetWidth],
opacity: [0, 1],
easing: 'easeOutSine',
begin: () => {
el.classList.remove('display-none');
},
complete: () => {
this.showContent = true;
},
});
}

componentDidLoad() {
Expand All @@ -186,33 +198,50 @@ export class Drawer {
<Host
class={{
'drawer-container': true,
'd-none': true,
'display-none': true,
}}
style={{
width: this.width === 'auto' ? this.width : `${this.width}rem`,
'min-width': `${this.minWidth}rem`,
width: '0',
'max-width': `${this.maxWidth}rem`,
height: this.fullHeight ? '100%' : 'auto',
overflow: 'hidden',
}}
ref={(el) => (this.divElement = el as HTMLElement)}
data-testid="container"
id="div-container"
>
<div class="header">
<div class="header-content">
<slot name="header"></slot>
<div
style={{
width:
this.width === 'auto'
? 'auto'
: `${this.getConstrainedWidth(this.width)}rem`,
}}
>
<div class="header">
<div class="header-content">
<slot name="header"></slot>
</div>
<ix-icon-button
class="close-button"
style={{
display: this.showContent ? 'block' : 'none',
}}
icon={'close'}
size="24"
ghost
onClick={() => this.onCloseClicked()}
data-testid="close-button"
></ix-icon-button>
</div>
<div
class="content"
style={{
display: this.showContent ? 'block' : 'none',
}}
>
<slot></slot>
</div>
<ix-icon-button
class="close-button"
icon={'close'}
size="24"
ghost
onClick={() => this.onCloseClicked()}
data-testid="close-button"
></ix-icon-button>
</div>
<div class="content">
<slot></slot>
</div>
</Host>
);
Expand Down
31 changes: 18 additions & 13 deletions packages/core/src/components/input-group/input-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import { Component, Element, h, Host, State } from '@stencil/core';
import { getSlottedElements } from '../utils/shadow-dom';

/**
* @deprecated since 3.0.0. Will be removed with 4.0.0.
* Use the 'ix-input' component instead
*/
@Component({
tag: 'ix-input-group',
styleUrl: 'input-group.scss',
Expand All @@ -23,6 +27,9 @@ export class InputGroup {
@State() inputPaddingLeft = 0;
@State() inputPaddingRight = 0;

startSlotRef?: HTMLElement;
endSlotRef?: HTMLElement;

private get inputElement() {
return this.hostElement.querySelector('input') as HTMLInputElement;
}
Expand Down Expand Up @@ -100,12 +107,8 @@ 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;
Expand Down Expand Up @@ -134,16 +137,12 @@ export class InputGroup {
}

private endSlotChanged() {
const slot = this.hostElement.shadowRoot!.querySelector(
'slot[name="input-end"]'
)!;

setTimeout(() => {
this.inputPaddingRight = 15 + this.getChildrenWidth(slot);
this.inputPaddingRight = 15 + this.getChildrenWidth(this.endSlotRef);
});
}

private getChildrenWidth(slotElement: Element) {
private getChildrenWidth(slotElement: Element | undefined) {
if (!slotElement) {
return 0;
}
Expand All @@ -166,11 +165,17 @@ export class InputGroup {
return (
<Host class={{ disabled: this.disabled }}>
<div class="group group-start">
<slot name="input-start"></slot>
<slot
ref={(el) => (this.startSlotRef = el as HTMLElement)}
name="input-start"
></slot>
</div>
<slot></slot>
<div class="group group-end">
<slot name="input-end"></slot>
<slot
ref={(el) => (this.endSlotRef = el as HTMLElement)}
name="input-end"
></slot>
</div>
</Host>
);
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/tests/drawer/drawer.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,18 @@ regressionTest.describe('drawer', () => {
await page.waitForTimeout(2000);
expect(await page.screenshot()).toMatchSnapshot();
});

regressionTest('input-group', async ({ page }) => {
await page.goto('drawer/input-group');
await page.locator('ix-button').click();
await page.waitForSelector('ix-drawer[style*="opacity: 1;"]');
expect(await page.screenshot({ animations: 'disabled' })).toMatchSnapshot();
});

regressionTest('inside container', async ({ page }) => {
await page.goto('drawer/inside-container');
await page.locator('ix-button').click();
await page.waitForSelector('ix-drawer[style*="opacity: 1;"]');
expect(await page.screenshot({ animations: 'disabled' })).toMatchSnapshot();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading