-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
allowMissing option permits non-DOM-backed regions #1984
allowMissing option permits non-DOM-backed regions #1984
Conversation
Hey @duncanbeevers - what cool behaviors have you built? |
We use this type of control for a media library manager / player. We use these subclasses to implement different views of the library (posters, list, and details views) In this case, if the media is currently playing, some representations include a little progress meter, while others don't. |
oh fun. media players are one of those canonical widgets. I'd love to see a more flushed out breakdown of how you designed the player and the media types. I think you're right that we should have a solution for flagging off the empty region error.
My preference is for solution 3 because this seems like something you want to disable on a class-by-class basis. What do you think? |
The behavior definitely makes sense to configure on a class-by-class basis, but unfortunately we exclusively set up regions in LayoutViews, and so do no manual Region instantiation. I guess this means we'd have to create our own RegionManager that dispensed these subclassed Regions. |
@duncanbeevers I think we could do this: new Marionette.LayoutView({
regions: {
"cat": ".doge",
"wow": {
allowMissing: false,
regionClass: Coin
}
}
}) |
10c09a2
to
afd04f9
Compare
I've pushed a slightly different PR based on your feedback.
This allows us to change our region definitions to this form. regions: {
progressRegion: {
selector: '.progress-region',
allowMissing: true
}
} |
This looks good to me. Mind updating the docs as well, which will mean updating the docs/region.md file and the api/region.jsdoc file. We hope to roll out the new api in the neartime future. |
Let's hold off on this. I'm not sure if I think that |
afd04f9
to
1f5998d
Compare
@jmeas Do you have any concrete feedback? I'd love to discuss the right way to go about handling this situation, whether it's making a publicly-overridable region method like As it stands, |
I didn't mean to hold this up for so long. The rest of the team can make a decision on which to merge – I doubt I'll have time to think more on this issue. Thanks for the great PRs, @duncanbeevers! |
Hey @duncanbeevers, thanks for offering #2025 as an alternative approach. We would definitely like to make it possible to specify that a region can infact have a missing element. I'd like to hear which approach you prefer. I've spoken with @jmeas and either one is fine with us. Personally, I'm inclined to go with this approach because it is easier to specify in the Region setup that the region will not insist on having an element. regions: {
progressRegion: {
selector: '.progress-region',
allowMissing: true
}
} One side thought, maybe |
f902844
to
644d56d
Compare
I modified this PR a bit to ensure views provided to non-backed regions aren't rendered. The |
644d56d
to
5128d59
Compare
I'm not sure what's up with the TravisCI failures. The tests are green on my machine and the failures appear unrelated to the changes I've proposed here. |
Hmm, @duncanbeevers - it looks like the PR wants to merge onto master. mind opening a new PR against minor?
not sure why Behavior tests would start failing. hopefully the new PR will fix that.... |
@jasonLaster Reopened against |
We use a Layout parent class to capture behavior common to a number of subclass views.
There are behaviors that drive regions which exist in some of the subclasses and not in others. Prior to #1024 / #1050 these missing regions would simply act as no-ops in these subclass views, but now they throw errors.
In order to accommodate this use-case, I added an
allowMissing
option to be passed in throughshow
, which suppresses the error-throwing behavior in_ensureElement
, and turnsappendHtml
into a no-op in the case of a missingthis
.el`.