Skip to content

Commit 5947b0f

Browse files
committed
refactor(input, textarea): add dir watch
1 parent 737082a commit 5947b0f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

core/src/components/input/input.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,22 @@ export class Input implements ComponentInterface {
338338
}
339339
}
340340

341+
/**
342+
* dir is a globally enumerated attribute.
343+
* As a result, creating these as properties
344+
* can have unintended side effects. Instead, we
345+
* listen for attribute changes and inherit them
346+
* to the inner `<input>` element.
347+
*/
348+
@Watch('dir')
349+
onDirChanged(newValue: string) {
350+
this.inheritedAttributes = {
351+
...this.inheritedAttributes,
352+
dir: newValue,
353+
};
354+
forceUpdate(this);
355+
}
356+
341357
componentWillLoad() {
342358
this.inheritedAttributes = {
343359
...inheritAriaAttributes(this.el),

core/src/components/textarea/textarea.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,22 @@ export class Textarea implements ComponentInterface {
261261
this.runAutoGrow();
262262
}
263263

264+
/**
265+
* dir is a globally enumerated attribute.
266+
* As a result, creating these as properties
267+
* can have unintended side effects. Instead, we
268+
* listen for attribute changes and inherit them
269+
* to the inner `<input>` element.
270+
*/
271+
@Watch('dir')
272+
onDirChanged(newValue: string) {
273+
this.inheritedAttributes = {
274+
...this.inheritedAttributes,
275+
dir: newValue,
276+
};
277+
forceUpdate(this);
278+
}
279+
264280
/**
265281
* The `ionChange` event is fired when the user modifies the textarea's value.
266282
* Unlike the `ionInput` event, the `ionChange` event is fired when

0 commit comments

Comments
 (0)