Skip to content

Commit 19ac238

Browse files
sean-perkinscerkinerliamdebeasi
authored
fix(img): draggable attribute is now inherited to inner img element (#24781)
Resolves #21325 Co-authored-by: Celilsemi Sam Erkiner <celilsemi@erkiner.com> Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
1 parent 243f673 commit 19ac238

File tree

13 files changed

+133
-27
lines changed

13 files changed

+133
-27
lines changed

core/src/components/back-button/back-button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { config } from '../../global/config';
55
import { getIonMode } from '../../global/ionic-global';
66
import { AnimationBuilder, Color } from '../../interface';
77
import { ButtonInterface } from '../../utils/element-interface';
8-
import { inheritAttributes } from '../../utils/helpers';
8+
import { Attributes, inheritAttributes } from '../../utils/helpers';
99
import { createColorClasses, hostContext, openURL } from '../../utils/theme';
1010

1111
/**
@@ -24,7 +24,7 @@ import { createColorClasses, hostContext, openURL } from '../../utils/theme';
2424
shadow: true
2525
})
2626
export class BackButton implements ComponentInterface, ButtonInterface {
27-
private inheritedAttributes: { [k: string]: any } = {};
27+
private inheritedAttributes: Attributes = {};
2828

2929
@Element() el!: HTMLElement;
3030

core/src/components/breadcrumb/breadcrumb.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { chevronForwardOutline, ellipsisHorizontal } from 'ionicons/icons';
33

44
import { getIonMode } from '../../global/ionic-global';
55
import { AnimationBuilder, BreadcrumbCollapsedClickEventDetail, Color, RouterDirection } from '../../interface';
6-
import { inheritAttributes } from '../../utils/helpers';
6+
import { Attributes, inheritAttributes } from '../../utils/helpers';
77
import { createColorClasses, hostContext, openURL } from '../../utils/theme';
88

99
/**
@@ -22,7 +22,7 @@ import { createColorClasses, hostContext, openURL } from '../../utils/theme';
2222
shadow: true
2323
})
2424
export class Breadcrumb implements ComponentInterface {
25-
private inheritedAttributes: { [k: string]: any } = {};
25+
private inheritedAttributes: Attributes = {};
2626
private collapsedRef?: HTMLElement;
2727

2828
/** @internal */

core/src/components/button/button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop
33
import { getIonMode } from '../../global/ionic-global';
44
import { AnimationBuilder, Color, RouterDirection } from '../../interface';
55
import { AnchorInterface, ButtonInterface } from '../../utils/element-interface';
6-
import { hasShadowDom, inheritAttributes } from '../../utils/helpers';
6+
import { Attributes, hasShadowDom, inheritAttributes } from '../../utils/helpers';
77
import { createColorClasses, hostContext, openURL } from '../../utils/theme';
88

99
/**
@@ -28,7 +28,7 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
2828
private inItem = false;
2929
private inListHeader = false;
3030
private inToolbar = false;
31-
private inheritedAttributes: { [k: string]: any } = {};
31+
private inheritedAttributes: Attributes = {};
3232

3333
@Element() el!: HTMLElement;
3434

core/src/components/header/header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, ComponentInterface, Element, Host, Prop, h, writeTask } from '@stencil/core';
22

33
import { getIonMode } from '../../global/ionic-global';
4-
import { componentOnReady, inheritAttributes } from '../../utils/helpers';
4+
import { Attributes, componentOnReady, inheritAttributes } from '../../utils/helpers';
55
import { hostContext } from '../../utils/theme';
66

77
import { cloneElement, createHeaderIndex, handleContentScroll, handleHeaderFade, handleToolbarIntersection, setHeaderActive, setToolbarBackgroundOpacity } from './header.utils';
@@ -21,7 +21,7 @@ export class Header implements ComponentInterface {
2121
private contentScrollCallback?: any;
2222
private intersectionObserver?: any;
2323
private collapsibleMainHeader?: HTMLElement;
24-
private inheritedAttributes: { [k: string]: any } = {};
24+
private inheritedAttributes: Attributes = {};
2525

2626
@Element() el!: HTMLElement;
2727

core/src/components/img/img.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop, State, Watch, h } from '@stencil/core';
22

33
import { getIonMode } from '../../global/ionic-global';
4+
import { Attributes, inheritAttributes } from '../../utils/helpers';
45

56
/**
67
* @part image - The inner `img` element.
@@ -13,6 +14,7 @@ import { getIonMode } from '../../global/ionic-global';
1314
export class Img implements ComponentInterface {
1415

1516
private io?: IntersectionObserver;
17+
private inheritedAttributes: Attributes = {};
1618

1719
@Element() el!: HTMLElement;
1820

@@ -45,6 +47,10 @@ export class Img implements ComponentInterface {
4547
/** Emitted when the img fails to load */
4648
@Event() ionError!: EventEmitter<void>;
4749

50+
componentWillLoad() {
51+
this.inheritedAttributes = inheritAttributes(this.el, ['draggable']);
52+
}
53+
4854
componentDidLoad() {
4955
this.addIO();
5056
}
@@ -100,17 +106,38 @@ export class Img implements ComponentInterface {
100106
}
101107

102108
render() {
109+
const { loadSrc, alt, onLoad, loadError, inheritedAttributes } = this;
110+
const { draggable } = inheritedAttributes;
103111
return (
104112
<Host class={getIonMode(this)}>
105113
<img
106114
decoding="async"
107-
src={this.loadSrc}
108-
alt={this.alt}
109-
onLoad={this.onLoad}
110-
onError={this.loadError}
115+
src={loadSrc}
116+
alt={alt}
117+
onLoad={onLoad}
118+
onError={loadError}
111119
part="image"
120+
draggable={isDraggable(draggable)}
112121
/>
113122
</Host>
114123
);
115124
}
116125
}
126+
127+
/**
128+
* Enumerated strings must be set as booleans
129+
* as Stencil will not render 'false' in the DOM.
130+
* The need to explicitly render draggable="true"
131+
* as only certain elements are draggable by default.
132+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable.
133+
*/
134+
const isDraggable = (draggable?: string): boolean | undefined => {
135+
switch (draggable) {
136+
case 'true':
137+
return true;
138+
case 'false':
139+
return false;
140+
default:
141+
return undefined;
142+
}
143+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { newE2EPage } from '@stencil/core/testing';
2+
3+
test('img: draggable', async () => {
4+
const page = await newE2EPage({
5+
url: '/src/components/img/test/draggable?ionic:_testing=true'
6+
});
7+
8+
const imgDraggableTrue = await page.find('#img-draggable-true >>> img');
9+
expect(imgDraggableTrue.getAttribute('draggable')).toEqual('true');
10+
11+
const imgDraggableFalse = await page.find('#img-draggable-false >>> img');
12+
expect(imgDraggableFalse.getAttribute('draggable')).toEqual('false');
13+
14+
const imgDraggableUnset = await page.find('#img-draggable-unset >>> img');
15+
expect(imgDraggableUnset.getAttribute('draggable')).toEqual(null);
16+
17+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Img - Draggable</title>
7+
<meta name="viewport"
8+
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
9+
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
10+
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
11+
<script src="../../../../../scripts/testing/scripts.js"></script>
12+
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
13+
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
14+
15+
<style>
16+
ion-img::part(image) {
17+
border: 1px solid rgba(0, 0, 0, 0.5);
18+
border-radius: 4px;
19+
height: 100px;
20+
width: 100px;
21+
}
22+
</style>
23+
</head>
24+
25+
<body>
26+
<ion-app>
27+
28+
<ion-header>
29+
<ion-toolbar>
30+
<ion-title>Img - Draggable</ion-title>
31+
</ion-toolbar>
32+
</ion-header>
33+
34+
<ion-content class="ion-padding">
35+
<ion-list>
36+
<ion-item>
37+
<ion-label>Draggable</ion-label>
38+
<ion-img id="img-draggable-true" draggable="true"
39+
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAARQAQMAAAA2ut43AAAABlBMVEXMzMz////TjRV2AAAEPUlEQVR42u3RMREAMBDDs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AwMDAwMDAwMDAwMDAwMDAwMDFxtb4GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrYJ+BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBq+0tMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwcBXsMzAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMHC1vQUGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgaugn0GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGjvYD5WuYrpZqdmcAAAAASUVORK5CYII=">
40+
</ion-img>
41+
</ion-item>
42+
<ion-item>
43+
<ion-label>Not draggable (draggable="false")</ion-label>
44+
<ion-img id="img-draggable-false" draggable="false"
45+
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAARQAQMAAAA2ut43AAAABlBMVEXMzMz////TjRV2AAAEPUlEQVR42u3RMREAMBDDsPAn/eXhavOq87Ztu7u7+6eBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBf2hvgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgatgn4GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGr7S0wMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDBwFewzMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwcLW9BQYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBq6CfQYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBg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GBgYGBgYGBgYGBgYOAq2GdgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGDgansLDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMXAX7DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDFxtb4GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrYJ+BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBq+0tMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwcBXsMzAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMHC1vQUGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgaugn0GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGjvYD5WuYrpZqdmcAAAAASUVORK5CYII">
52+
</ion-img>
53+
</ion-item>
54+
</ion-list>
55+
</ion-content>
56+
57+
</ion-app>
58+
</body>
59+
60+
</html>

core/src/components/input/input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Build, Component, ComponentInterface, Element, Event, EventEmitter, Hos
22

33
import { getIonMode } from '../../global/ionic-global';
44
import { AutocompleteTypes, Color, InputChangeEventDetail, StyleEventDetail, TextFieldTypes } from '../../interface';
5-
import { debounceEvent, findItemLabel, inheritAttributes } from '../../utils/helpers';
5+
import { Attributes, debounceEvent, findItemLabel, inheritAttributes } from '../../utils/helpers';
66
import { createColorClasses } from '../../utils/theme';
77

88
/**
@@ -21,7 +21,7 @@ export class Input implements ComponentInterface {
2121
private nativeInput?: HTMLInputElement;
2222
private inputId = `ion-input-${inputIds++}`;
2323
private didBlurAfterEdit = false;
24-
private inheritedAttributes: { [k: string]: any } = {};
24+
private inheritedAttributes: Attributes = {};
2525
private isComposing = false;
2626

2727
/**

core/src/components/menu-button/menu-button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { config } from '../../global/config';
55
import { getIonMode } from '../../global/ionic-global';
66
import { Color } from '../../interface';
77
import { ButtonInterface } from '../../utils/element-interface';
8-
import { inheritAttributes } from '../../utils/helpers';
8+
import { Attributes, inheritAttributes } from '../../utils/helpers';
99
import { menuController } from '../../utils/menu-controller';
1010
import { createColorClasses, hostContext } from '../../utils/theme';
1111
import { updateVisibility } from '../menu-toggle/menu-toggle-util';
@@ -25,7 +25,7 @@ import { updateVisibility } from '../menu-toggle/menu-toggle-util';
2525
shadow: true
2626
})
2727
export class MenuButton implements ComponentInterface, ButtonInterface {
28-
private inheritedAttributes: { [k: string]: any } = {};
28+
private inheritedAttributes: Attributes = {};
2929

3030
@Element() el!: HTMLIonSegmentElement;
3131

core/src/components/menu/menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getIonMode } from '../../global/ionic-global';
55
import { Animation, Gesture, GestureDetail, MenuChangeEventDetail, MenuI, Side } from '../../interface';
66
import { getTimeGivenProgression } from '../../utils/animation/cubic-bezier';
77
import { GESTURE_CONTROLLER } from '../../utils/gesture';
8-
import { assert, clamp, inheritAttributes, isEndSide as isEnd } from '../../utils/helpers';
8+
import { Attributes, assert, clamp, inheritAttributes, isEndSide as isEnd } from '../../utils/helpers';
99
import { menuController } from '../../utils/menu-controller';
1010
import { getOverlay } from '../../utils/overlays';
1111

@@ -43,7 +43,7 @@ export class Menu implements ComponentInterface, MenuI {
4343
contentEl?: HTMLElement;
4444
lastFocus?: HTMLElement;
4545

46-
private inheritedAttributes: { [k: string]: any } = {};
46+
private inheritedAttributes: Attributes = {};
4747

4848
private handleFocus = (ev: FocusEvent) => {
4949
/**

core/src/components/range/range.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop
22

33
import { getIonMode } from '../../global/ionic-global';
44
import { Color, Gesture, GestureDetail, KnobName, RangeChangeEventDetail, RangeValue, StyleEventDetail } from '../../interface';
5-
import { clamp, debounceEvent, getAriaLabel, inheritAttributes, renderHiddenInput } from '../../utils/helpers';
5+
import { Attributes, clamp, debounceEvent, getAriaLabel, inheritAttributes, renderHiddenInput } from '../../utils/helpers';
66
import { isRTL } from '../../utils/rtl';
77
import { createColorClasses, hostContext } from '../../utils/theme';
88

@@ -38,7 +38,7 @@ export class Range implements ComponentInterface {
3838
private hasFocus = false;
3939
private rangeSlider?: HTMLElement;
4040
private gesture?: Gesture;
41-
private inheritedAttributes: { [k: string]: any } = {};
41+
private inheritedAttributes: Attributes = {};
4242

4343
@Element() el!: HTMLIonRangeElement;
4444

core/src/components/textarea/textarea.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Build, Component, ComponentInterface, Element, Event, EventEmitter, Hos
22

33
import { getIonMode } from '../../global/ionic-global';
44
import { Color, StyleEventDetail, TextareaChangeEventDetail } from '../../interface';
5-
import { debounceEvent, findItemLabel, inheritAttributes, raf } from '../../utils/helpers';
5+
import { Attributes, debounceEvent, findItemLabel, inheritAttributes, raf } from '../../utils/helpers';
66
import { createColorClasses } from '../../utils/theme';
77

88
/**
@@ -22,7 +22,7 @@ export class Textarea implements ComponentInterface {
2222
private inputId = `ion-textarea-${textareaIds++}`;
2323
private didBlurAfterEdit = false;
2424
private textareaWrapper?: HTMLElement;
25-
private inheritedAttributes: { [k: string]: any } = {};
25+
private inheritedAttributes: Attributes = {};
2626

2727
/**
2828
* This is required for a WebKit bug which requires us to

core/src/utils/helpers.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export const componentOnReady = (el: any, callback: any) => {
7575
}
7676
}
7777

78+
export type Attributes = { [key: string]: any };
79+
7880
/**
7981
* Elements inside of web components sometimes need to inherit global attributes
8082
* set on the host. For example, the inner input in `ion-input` should inherit
@@ -86,7 +88,7 @@ export const componentOnReady = (el: any, callback: any) => {
8688
* does not trigger a re-render.
8789
*/
8890
export const inheritAttributes = (el: HTMLElement, attributes: string[] = []) => {
89-
const attributeObject: { [k: string]: any } = {};
91+
const attributeObject: Attributes = {};
9092

9193
attributes.forEach(attr => {
9294
if (el.hasAttribute(attr)) {
@@ -233,8 +235,8 @@ export const getAriaLabel = (componentEl: HTMLElement, inputId: string): { label
233235
labelText = label.textContent;
234236
label.setAttribute('aria-hidden', 'true');
235237

236-
// if there is no label, check to see if the user has provided
237-
// one by setting an id on the component and using the label element
238+
// if there is no label, check to see if the user has provided
239+
// one by setting an id on the component and using the label element
238240
} else if (componentId.trim() !== '') {
239241
label = document.querySelector(`label[for="${componentId}"]`);
240242

@@ -356,7 +358,7 @@ export const debounce = (func: (...args: any[]) => void, wait = 0) => {
356358
*
357359
* @returns whether the keys are the same and the values are shallow equal.
358360
*/
359-
export const shallowEqualStringMap = (map1: {[k: string]: any} | undefined, map2: {[k: string]: any} | undefined): boolean => {
361+
export const shallowEqualStringMap = (map1: { [k: string]: any } | undefined, map2: { [k: string]: any } | undefined): boolean => {
360362
map1 ??= {};
361363
map2 ??= {};
362364

@@ -380,4 +382,4 @@ export const shallowEqualStringMap = (map1: {[k: string]: any} | undefined, map2
380382
}
381383

382384
return true;
383-
}
385+
}

0 commit comments

Comments
 (0)