-
Notifications
You must be signed in to change notification settings - Fork 42
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
Make paper-drawer-panel#rightDrawer default to true in RTL #130
Conversation
@@ -550,6 +552,10 @@ | |||
this._transition = true; | |||
}, | |||
|
|||
_isRTL: function() { | |||
return window.getComputedStyle(this).direction == 'rtl'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
Thanks for fixing this @danbeam. The test is still failing, do you know why? |
according to @esprehn I'm hitting a bug where calling |
@danbeam does it help if you set |
would this help? var drawer;
setup(function() {
drawer = fixture('rtl-drawer');
});
test('rtl-drawer defaults rightDrawer to true', function(done) {
flush(function() {
expect(drawer.rightDrawer).to.be.true;
done();
});
}); |
One of the reasons why tests are failing is because you are overriding rightDrawer: {
type: Boolean,
value: null
}
...
attached: function() {
if (this.rightDrawer === null) {
this.rightDrawer = this._isRTL();
}
} |
@keanulee that helps and fixes the issue of this: var paperDrawerPanel = document.createElement('paper-drawer-panel');
paperDrawerPanel.rightDrawer = ...;
document.body.appendChild(paperDrawerPanel); // overriden but doesn't pass all tests yet |
@danbeam There's only one failing test, and here's the fix :) In test/small-devices.html, change the contents of the style tag to be the following instead: <style is="custom-style">
body {
margin: 0;
padding: 0;
}
.notransition {
--paper-drawer-panel-drawer-container: {
transition: none !important;
};
}
</style> The tests actually passes in ShadyDOM (i.e. improper style scoping), but breaks in ShadowDOM because |
@danbeam friendly ping. |
so, what I don't like about my patch:
@blasten or @keanulee: thoughts? additionally, if |
@danbeam Yeah, that's not ideal, and it does cause the animation. In One suggestion is to try to set |
Chrome already does set it externally. It turns out Chrome's UI sets That doesn't mean I did implement a prototype along the lines of: Polymer({
properties: {
_rightDrawer: Boolean,
_defaultDirection: String,
get rightDrawer() {
return this._rightDrawer === undefined ? this._defaultDirection == 'rtl' : this._rightDrawer;
},
set rightDrawer(rightDrawer) {
this._rightDrawer = rightDrawer;
},
},
attached: function() {
this._defaultDirection = window.getComputedStyle(this).direction;
},
}); but didn't find it much better and didn't know how property change accessors would work (maybe switch them all from at least this way we could determine which thing changed and only animatedly change if |
The conclusion here was that the direction should be set externally. |
@danbeam should we close this PR? |
possibly fixes #101
i also thought about creating a
for folks to call if directionality changes, but:
rightDrawer
is already@public
so this doesn't add much value (authors can do this themselves if they wish)/cc @blasten @frankiefu