Skip to content
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

fix p1 accordion issues #1730

Merged
merged 2 commits into from
Mar 14, 2024
Merged

fix p1 accordion issues #1730

merged 2 commits into from
Mar 14, 2024

Conversation

kishore03109
Copy link
Contributor

@kishore03109 kishore03109 commented Dec 6, 2023

Problem

This PR attempts to fix the functional issues wrt to Accordions.
Will leave paddings as separate since those will be easier to fix + don't really need much context to be worked on.

Fix bunch of stuff here

To test template stuff, need to make changes to kishore-test

Corresponding template pr: isomerpages/isomerpages-template#361 (doesnt block this pr since complex blocks are behind feature flag anyway)

deprior padding related fix as design is not 100% sure about it yet + padding are easier to fix so no biggie

Screenshot 2023-12-06 at 4 15 20 PM

Reviewer notes

The approach for this PR would look weird considering the buttons are not bubble-menued.
I did try it but it kept popping up on every individual cell (similar behaviour to our table stuff). I somehow couldnt get it to work since (note that there were 2 levels of abstraction here bubbleMenu in react/src -> bubblemenu in the extensions). As of now, the API is not extensible enough to allow for this to happen, and this wasnt just a trivial as a .extend that we do for our other extensions like table .There might be a way, please let me know if that is the case, but i time boxed this effort and just wrapped it around NodeViewWrapper to at least land something in main line first.

This is still feature flagged and thus safe to merge to production for now, but hopefully p1 issues are all fixed and the pending stuff are just padding css stuff

Copy link
Contributor Author

kishore03109 commented Dec 6, 2023

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @kishore03109 and the rest of your teammates on Graphite Graphite

children,
}: PropsWithChildren<BlockWrapperProps>): JSX.Element => {
return (
<Box as={NodeViewWrapper}>
<Box position="relative" maxW="36.5rem" data-group>
{isSelected && <>{otherButtons}</>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could i ask why we require this? i think an alternative that we might wish to consider here would be to create another component that uses BlockViewWrapper and does this functionality. the reason for doing so is that this otherButtons is kind of a unique use case and kinda pollutes the responsibility of BlockWrapper (thus tempting other devs to add mroe things here)

if that doesn't work well, i'm ok w/ this if we have a better fitting name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, ideally we should be using bubble menu for this, but somehow I couldnt get the bubble menu to work to target the component as a whole, it targets the individual cells which does not fit our requirement.

I am not sure if I understood your suggestion correctly, if I were to create another component wouldnt that copy over quite a bit of code ah? Maybe can quick pair if you have bandwidth please!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's the bubble menu, wouldn't it be possible to check if the node that's active is the detailSummary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the issue is not to check whether the node is active, the issue was revolving more around detailSummary being selected but the popper js targeting each detail summary rather than the entire detail group

Comment on lines +74 to +92
Backspace: () => {
const { schema, selection } = this.editor.state
const { empty, $anchor } = selection

if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary) {
return false
}

if ($anchor.parentOffset !== 0) {
return this.editor.commands.command(({ tr }) => {
const start = $anchor.pos - 1
const end = $anchor.pos
tr.delete(start, end)
return true
})
}
return this.editor.commands.removeDetail()
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idt this works - adding a keyboard shortcut would invoke it for every associated keypress (Backspace) here (unless we copied over the backspace logic from tiptap)

i think if the intended outcome is to delete the block as a whole, we might wanna just make the parent node defining so that backspace consumes it atomically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh the purpose of this is not to delete the block as a whole, is to actually have a functional backspace key press for the titles, but I should not be able to backspace on an empty title to delete the entire block (deletion of the entire block should be in the button)!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fine, but because this triggers for every keypress on backspace, it might destructively interfere with other nodes that don't adhere to the default backspace behaviour.

have we tried deleting:

  1. nested nodes (cards) with this?
  2. defining nodes?
  3. plain text?

as this uses the selection and checks if the selection is empty, we might mess up on deletion on plain text w/o a selection (haven't tried)

Copy link
Contributor Author

@kishore03109 kishore03109 Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey good point!
regarding the selection, the delete button selects the node as a whole, and therefore this should not accidently delete another selected text for example.

regarding the

  • nested card, deletion works as expected, the cards is deleted as expected
  • defining nodes, eg text? abit confused about this point ps, can clarify here
  • plain text works too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defining nodes are those that should be deleted as a group! (i think iframe is, for one)

if this works, then am ok w/ it as chance of destructive interference seems low - tiptap might dispatch the event to the specific node itself, in which case idt my concerns stand.

@kishore03109 kishore03109 force-pushed the 12-06-fix_p1_accordion_issues branch from 9447813 to 7771112 Compare December 28, 2023 02:06
@kishore03109 kishore03109 requested review from seaerchin and a team December 28, 2023 02:31
@kishore03109 kishore03109 marked this pull request as draft January 26, 2024 10:30
@kishore03109 kishore03109 marked this pull request as ready for review January 31, 2024 08:00
Comment on lines +74 to +92
Backspace: () => {
const { schema, selection } = this.editor.state
const { empty, $anchor } = selection

if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary) {
return false
}

if ($anchor.parentOffset !== 0) {
return this.editor.commands.command(({ tr }) => {
const start = $anchor.pos - 1
const end = $anchor.pos
tr.delete(start, end)
return true
})
}
return this.editor.commands.removeDetail()
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defining nodes are those that should be deleted as a group! (i think iframe is, for one)

if this works, then am ok w/ it as chance of destructive interference seems low - tiptap might dispatch the event to the specific node itself, in which case idt my concerns stand.

Copy link

mergify bot commented Mar 7, 2024

This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers

@kishore03109 kishore03109 force-pushed the 12-06-fix_p1_accordion_issues branch from c517c84 to de4b616 Compare March 13, 2024 00:25
@kishore03109 kishore03109 merged commit 89198d5 into develop Mar 14, 2024
9 checks passed
@mergify mergify bot deleted the 12-06-fix_p1_accordion_issues branch March 14, 2024 00:31
@dcshzj dcshzj mentioned this pull request Mar 14, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants