-
Notifications
You must be signed in to change notification settings - Fork 179
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
Remove objectWithout
usage from elements
package
#12209
Conversation
Plugin builds for 344e0a3 are ready 🛎️!
|
@@ -25,18 +21,15 @@ import createNewElement from './createNewElement'; | |||
import duplicateElement from './duplicateElement'; | |||
|
|||
const duplicatePage = (oldPage) => { | |||
// Remove title and postId for inserting the page. | |||
// Remove title and templateId for inserting the page. |
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 tried to test this part and can't see when would a template / post ID be assigned at all. Thought that perhaps when inserting a page template and then duplicating it but doesn't seem like it. Were you able to test in which case we need to remove the title and ID when duplicating?
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.
Indeed, doesn't look like that happens at all.
I tried inserting default page templates and custom saved page templates, but there's no templateId
leaking into this.
Looking at handlePageClick
, it's specifically omitted:
web-stories-wp/packages/story-editor/src/components/library/panes/pageTemplates/templateList.js
Lines 72 to 76 in 7f3af11
const handlePageClick = useCallback( | |
({ templateId, version, title, ...page }) => { | |
// Just using destructuring above so we don't pass unnecessary props to addPage(). | |
const duplicatedPage = duplicatePage(page); | |
addPage({ page: duplicatedPage }); |
So yeah, seems like it's safe to remove this comment & check.
For context, originally introduce in #7290 and then adjusted in #7318
Size Change: -102 B (0%) Total Size: 2.68 MB
ℹ️ View Unchanged
|
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.
Looks good, makes sense to use the advanced language features.
// There's an exception for the background shape that should not get all the default attributes. | ||
if (attributes.isDefaultBackground) { | ||
return objectWithout(newElement, ['backgroundColor']); | ||
const { backgroundColor: _, ...newElementWithoutBgColor } = newElement; |
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.
Why rename it to _
if unused anyway?
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.
ESLint complained otherwise, surprisingly
Context
I just noticed this is the only reason for the dependency on the
design-system
package. That util is not used anywhere else (thestory-editor
has its own copy).Summary
Remove
objectWithout
usage fromelements
package, removing thedesign-system
package.Fixes a bug in
duplicatePage
too, I think..?Also removes a similar usage from the
patterns
package that I stumbled upon, making the code a bit more readableRelevant Technical Choices
To-do
User-facing changes
Testing Instructions
This PR can be tested by following these steps:
Reviews
Does this PR have a security-related impact?
Does this PR change what data or activity we track or use?
Does this PR have a legal-related impact?
Checklist
Type: XYZ
label to the PRFixes #