Skip to content

dir="auto" is changed by Dir directive #13855

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

Closed
alirezamirian opened this issue Oct 29, 2018 · 4 comments · Fixed by #13859
Closed

dir="auto" is changed by Dir directive #13855

alirezamirian opened this issue Oct 29, 2018 · 4 comments · Fixed by #13859
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@alirezamirian
Copy link

alirezamirian commented Oct 29, 2018

Bug:

Dir directive treats anything other than rtl and ltr as invalid value, and changes dir attribute to ltr which breaks dir="auto".

What is the expected behavior?

It should not change dir attribute. dir="auto" is perfectly fine.

What is the current behavior?

It changes it to ltr

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

All versions since this pull request is merged.

@alirezamirian
Copy link
Author

This fix can be used as a temporary workaround:

import {Directive, HostBinding, Input} from '@angular/core';

/**
 * This is fix for this issue in angular material: https://github.com/angular/material2/issues/13855
 * TODO: remove it when the issue is fixed
 */
@Directive({
  selector: '[dir]'
})
export class MaterialDirFixDirective {

  @HostBinding('attr.dir')
  @Input()
  dir: string;
}

@crisbeto
Copy link
Member

We probably shouldn't be overriding the attribute's value, but note that auto isn't supported in any of the Material components anyway.

@alirezamirian
Copy link
Author

alirezamirian commented Oct 29, 2018 via email

@crisbeto crisbeto self-assigned this Oct 29, 2018
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent has pr labels Oct 29, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 29, 2018
Currently we normalize any values that aren't `ltr` or `rtl` to `ltr` in order to have a predictable value when using the directionality in components, however this ends up overwriting the consumer's value which might not necessarily be used by Angular (e.g. setting it to `auto`). These changes switch to preserving the attribute while normalizing the value for when it gets injected.

Fixes angular#13855.
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 29, 2018
Currently we normalize any values that aren't `ltr` or `rtl` to `ltr` in order to have a predictable value when using the directionality in components, however this ends up overwriting the consumer's value which might not necessarily be used by Angular (e.g. setting it to `auto`). These changes switch to preserving the attribute while normalizing the value for when it gets injected.

Fixes angular#13855.
vivian-hu-zz pushed a commit that referenced this issue Nov 6, 2018
Currently we normalize any values that aren't `ltr` or `rtl` to `ltr` in order to have a predictable value when using the directionality in components, however this ends up overwriting the consumer's value which might not necessarily be used by Angular (e.g. setting it to `auto`). These changes switch to preserving the attribute while normalizing the value for when it gets injected.

Fixes #13855.
vivian-hu-zz pushed a commit that referenced this issue Nov 7, 2018
Currently we normalize any values that aren't `ltr` or `rtl` to `ltr` in order to have a predictable value when using the directionality in components, however this ends up overwriting the consumer's value which might not necessarily be used by Angular (e.g. setting it to `auto`). These changes switch to preserving the attribute while normalizing the value for when it gets injected.

Fixes #13855.
vivian-hu-zz pushed a commit that referenced this issue Nov 12, 2018
Currently we normalize any values that aren't `ltr` or `rtl` to `ltr` in order to have a predictable value when using the directionality in components, however this ends up overwriting the consumer's value which might not necessarily be used by Angular (e.g. setting it to `auto`). These changes switch to preserving the attribute while normalizing the value for when it gets injected.

Fixes #13855.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants