-
Notifications
You must be signed in to change notification settings - Fork 771
Not all custom responsive directives work as expected #776
Comments
The reason for the error on I can't replicate the behavior you're seeing for the |
@CaerusKaru I have updated my StackBlitz as advised (thanks for finding my mistakes). This fixes the custom fxFlex directives behaviour, so the only remaining ones with issues seem to be custom fxShow and fxLayoutGap directives. Thanks again. |
@Mufasa There's a lot to unpack in your StackBlitz demo. I've been unable to reproduce the Can you isolate the |
@CaerusKaru Here is a StackBlitz that demonstrates the It looks like it only has issues when mixed in with The top section has responsive |
@Mufasa doing a quick investigation into this I can see that the reason a lot of issues are occurring is due to the nature of how directives work in Angular and there being conflicting updates. For example, the issue with So what occurs is the following:
In my opinion, the base directives need to expose an API which can be consumed by our custom directives instead of our custom directives extending the base directives so that our directives are just passing through extra values for the custom breakpoints instead of re-executing the functionality (which is causing conflicts). I would envision something like this which would make adding custom breakpoints really simple; @Directive({
selector: `
[fxLayoutGap.mobile],
[fxLayoutGap.tablet],
[fxLayoutGap.web]
`
})
export class CustomLayoutGapDirective {
constructor(@Self() private _directive: LayoutGapDirective) {
// Would pass the current instance of the custom directive to the current instance of the
// base directive so that the base directive could connect / register / whatever it needed
_directive.registerCustomDirective(this);
}
@Input('fxLayoutGap.mobile')
set gapMobile(val) { this._directive.addCacheInput('gapMobile', val); }
@Input('fxLayoutGap.tablet')
set gapTablet(val) { this._directive.addCacheInput('gapTablet', val); }
@Input('fxLayoutGap.web')
set gapWeb(val) { this._directive.addCacheInput('gapWeb', val); }
} |
@charsleysa @Mufasa the show-hide behavior was a nasty side-effect, and Stefan if only you posted this before I went down the rabbit hole that was #798, you would've saved me so much time. Regardless, that behavior was patched in #891. The other directives probably still need investigation for similar behavior. I like your solution, but it has one problem: it still requires a user to register a default breakpoint on their host element. A user should be able to only specify one out of all registered directives and get intended behavior. Ideally, this would mean that they create a custom directive that extends the default directive, and then instead of importing The real ideal solution is to have a centralized style marshaller that can act as both data store for all elements and style generator. Unfortunately the implementation for such an approach is very complex and time-consuming, and may not be worth the effort. If you want to try, I'd be more than happy to offer some tips to get started and would of course review any PR submitted. |
@CaerusKaru Certainly - I'll be glad to help, just ping me when you want me to start testing please. |
@Mufasa Please test now with 7.0.0-beta.21 |
@CaerusKaru I updated my stackblitz (https://stackblitz.com/edit/flexlayout-eg9xpj) to the latest and it seems that the way custom directives are defined has changed. I have updated the code according to my understanding of how these should now be defined. However the latest release of flex-layout does not appear to have fixed the issues I was having. In fact it now appears to have introduced some new issues. It looks like not all of my custom breakpoints are being fired. When transitioning from the Also, as I increase the page width to beyond 1440px I expect by Is this a new issue or is it caused by some mistake I may have made in the way I have defined my custom breakpoints or in the way in which I have defined my custom directives? |
@Mufasa It ended up being a combination of factors. 1) You need to disable the orientation breakpoints (that's why you were getting conflicting data in ObservableMedia); and 2) there's a bug in the breakpoint processing part of the base directives that don't account for |
@CaerusKaru Great - I can confirm your modified stackblitz does indeed fix all the errors. Looking forward to the fix for breakpoint names with dots within them. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report
What is the expected behavior?
My customised responsive directives (fxLayout.x, fxHide.x, fxShow.x, fxFlex.x, and fxLayoutGap.x) should work as documented.
What is the current behavior?
fxFlex="..."
.fxLayoutGap="..."
. I have made some notes in the filesrc/app/app.component.html
to note some odd behaviour of this directive although it may be related to error being thrown - see bottom of this issue for details.What are the steps to reproduce?
StackBlitz example that demonstrates the issues: https://stackblitz.com/edit/flexlayout-eg9xpj
As you widen and narrow the browser window you should see the following custom breakpoints fire (defined in
src/app/custom-breakpoints.ts
):However, they only seem to fire correctly for fxLayout.x and fxHide.x directives.
The file
src/app/app.component.html
contains all the test HTML code.What is the use-case or motivation for changing an existing behavior?
All these directive should respect custom breakpoints as documented.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Flex-Layout v6.0.0-beta.16
Angular 6.0.3
Material 6.2.0
macOS High Sierra v10.13.4
Chrome Version 66.0.3359.181 (Official Build) (64-bit)
Is there anything else we should know?
In addition, if you look in the browsers Console then you will se these errors being reported intermittently as you adjust the browser windows width:
The text was updated successfully, but these errors were encountered: