-
Notifications
You must be signed in to change notification settings - Fork 109
fix/move wide page toggle #7514
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7514 +/- ##
===========================================
+ Coverage 46.65% 59.92% +13.27%
===========================================
Files 498 500 +2
Lines 42153 38218 -3935
Branches 1160 1140 -20
===========================================
+ Hits 19665 22904 +3239
+ Misses 22370 15206 -7164
+ Partials 118 108 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a913266 to
bcb708b
Compare
mejo-
left a comment
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 tackling this. I found some minor issues and have some questions 😆
|
The only thing that's missing from also fixing #6703 would be hiding the toggle in collectives as collectives has its own toggle. I'm unsure how best to achieve this though.
Alternatively we could make the toggle work on the collectives per page setting - but I wonder if that would be more confusing or less. update: I found a different way (f8ee194): |
bcb708b to
f8ee194
Compare
fc0d75d to
becbd1d
Compare
Signed-off-by: Max <[email protected]>
Next steps: * split it to a separate component. * move it into the remaining actions menu item. Signed-off-by: Max <[email protected]>
This way the editor width is adjusted before the session list loads. Signed-off-by: Max <[email protected]>
After closing and reopening the editor the full width value was read from initial state again. Use a singleton instead so the toggled state is persisted. Signed-off-by: Max <[email protected]>
If multiple editors are open (i.e. folder description and viewer) set the full width value on both of them using the event bus. Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
The component is used inside NcActions now. Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
becbd1d to
9804c10
Compare
src/composables/useEditorWidth.ts
Outdated
| const setByText = document.documentElement.style.getPropertyValue( | ||
| '--text-editor-max-width', | ||
| ) | ||
| return alreadySet && alreadySet !== setByText |
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.
I fear I don't fully understand the logic here. Both read the value of the css variable --text-editor-max-width, the first from the <body> element, the second from the root element (<html>). So Text attaches the variable to the root <html> element and Collectives attaches it to the <body> element and that's how you distinguish them?
In my tests with latest master branch of server, the latter is always empty, even if I open a text editor from the Files app. In other words I never see the full width toggle at the moment.
In general, this feels a bit brittle to me as it will make the fullWidth toggle disappear as soon as we change something with how --text-editor-max-width is set.
Maybe it's really better to be more explicit and make this configurable via the editorApi at editor.js?
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.
I just checked the code and it seems to me that actually both Text and Collectives set --text-editor-max-width on the root element: see https://github.com/nextcloud/collectives/blob/aeffe87608250a50d0eb99b526362616fa2e0eb2/src/css/editor.scss#L7 and
Line 7 in c74d204
| --text-editor-max-width: 80ch; |
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.
Also I don't understand why you use getComputedProperties(<element>) first and <element>.style second. Is this intended?
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.
What I am trying to do here is this:
- Read the effective value of
--text-editor-max-widthfor the document body. I'm usinggetComputedStyleso it does not matter where exactly the style is set - wether on the body element or:rootor in some other way. - Check if text has set a value already - for example because it was opened before. This value would always be set on
document.documentElement.style(as implemented below). - If 1. and 2. both have a value set - check if it's the same to determine if 1 is only set because of 2.
Now let me figure out why this is not working as intended.
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.
Okay... I see what's happening here. Text also set's the width on :root - twice in fact. So 1 returns a value even when 2 has not been set yet.
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.
Text set the --text-editor-max-width in css. I removed that as it will be set either externally or by useEditorWidth now.
d9b7cbe to
b76ac59
Compare
b76ac59 to
8f1c46b
Compare
mejo-
left a comment
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.
As discussed this PR is good to go from my side with two minor comments. One I put in the code, the other would be that a Cypress test would be great to protect against regresssions.
The collectives app has its own mechanism for setting the desired editor width. Detect the custom width being set and do not render the width toggle. Signed-off-by: Max <[email protected]>
This way it is easier to test and all the translation logic is in one place. Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
8f1c46b to
2050ce8
Compare
Uh oh!
There was an error while loading. Please reload this page.