Skip to content

Commit f42e39e

Browse files
fix(toolbar): allow slot to size to content to account for images (#30508)
Sets the `flex-basis` variable to `auto` if the slot contains an img to allow it to calculate the width using the image's intrinsic width. --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
1 parent 33dcf98 commit f42e39e

File tree

31 files changed

+87
-3
lines changed

31 files changed

+87
-3
lines changed

core/src/components/toolbar/test/basic/toolbar.e2e.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,67 @@ configs({ modes: ['ios', 'md', 'ionic-md'], palettes: ['light', 'dark'] }).forEa
180180
});
181181
});
182182
});
183+
184+
configs({ modes: ['ios', 'md', 'ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
185+
test.describe(title('toolbar: basic'), () => {
186+
test.describe(title('slot content'), () => {
187+
test('should not have visual regressions with slotted svgs', async ({ page }) => {
188+
await page.setContent(
189+
`
190+
<ion-header>
191+
<ion-toolbar>
192+
<img src="/src/components/toolbar/test/image.svg" slot="start"/>
193+
<ion-title>Toolbar</ion-title>
194+
<ion-img src="/src/components/toolbar/test/image.svg" slot="end"/>
195+
</ion-toolbar>
196+
</ion-header>
197+
`,
198+
config
199+
);
200+
201+
const header = page.locator('ion-header');
202+
await expect(header).toHaveScreenshot(screenshot(`toolbar-basic-slotted-svgs`));
203+
});
204+
205+
test('should not have visual regressions with slotted images', async ({ page }) => {
206+
await page.setContent(
207+
`
208+
<ion-header>
209+
<ion-toolbar>
210+
<img src="https://picsum.photos/id/237/50/50" slot="start" />
211+
<ion-title>Toolbar</ion-title>
212+
<ion-img src="https://picsum.photos/id/237/50/50" slot="end"></ion-img>
213+
</ion-toolbar>
214+
</ion-header>
215+
`,
216+
config
217+
);
218+
219+
const header = page.locator('ion-header');
220+
await expect(header).toHaveScreenshot(screenshot(`toolbar-basic-slotted-images`));
221+
});
222+
223+
test('should not have visual regressions with nested slotted images', async ({ page }) => {
224+
await page.setContent(
225+
`
226+
<ion-header>
227+
<ion-toolbar>
228+
<div slot="start">
229+
<img src="https://picsum.photos/id/237/50/50" />
230+
</div>
231+
<ion-title>Toolbar</ion-title>
232+
<div slot="end">
233+
<ion-img src="https://picsum.photos/id/237/50/50"></ion-img>
234+
</div>
235+
</ion-toolbar>
236+
</ion-header>
237+
`,
238+
config
239+
);
240+
241+
const header = page.locator('ion-header');
242+
await expect(header).toHaveScreenshot(screenshot(`toolbar-basic-nested-slotted-images`));
243+
});
244+
});
245+
});
246+
});

0 commit comments

Comments
 (0)