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(blocks): prevent indent when already a leaf block, prevent indent and unindent when already a top-level child #228

Merged

Conversation

itsrainingmani
Copy link
Contributor

This PR fixes Issue #209 .

There are 3 parts to this fix -

  • Modifying the indent event handler to only perform an indent if the block order for the current block is not 0
  • Modifying the unindent event handler to extract the id of the current page from the :current-route object of rfdb. If the id of the current page is equal to the parent ID of the node being unindented, prevent the unindent to keep the node within the current context.
  • Call preventDefault for tab and shift+tab key down events to prevent default browser tab behavior if an indent or unindent does not happen.

Potential Performance Optimization

We wanted to point out that there is some potential performance gain to be had by performing the if check at the earliest possible moment in the re-frame event handlers and thereby skipping the evaluation of possibly complex let bindings.

itsrainingmani and others added 3 commits July 8, 2020 00:33
…nt context (athensresearch#209)

If the node being unindented is the top-level node in the current context, prevent unindent by checking if parent node id is equal to id present in :current-route object.

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
…#209)

A leaf block is a block with block order 0. If the block order is 0, do not indent and return a no-op in the indent event handler

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
…e is no indent or unindent happening (athensresearch#209)

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
Copy link
Collaborator

@tangjeff0 tangjeff0 left a comment

Choose a reason for hiding this comment

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

Small adjustments. Great job team!

src/cljs/athens/events.cljs Outdated Show resolved Hide resolved
src/cljs/athens/events.cljs Outdated Show resolved Hide resolved
src/cljs/athens/events.cljs Outdated Show resolved Hide resolved
src/cljs/athens/events.cljs Outdated Show resolved Hide resolved
src/cljs/athens/events.cljs Outdated Show resolved Hide resolved
* Move the block zero check in indent event handler to the on-key-down handler since it doesn't require any re-frame or datascript subscriptions
* Rename context-root to context-root-uid and remove unnecessary comment in unindent event handler
* Use the stricter parent ID to context-root uid check instead of (and parent grandpa) in unindent event handler

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
@tangjeff0
Copy link
Collaborator

Just did a big refactor of blocks, can you resolve conflicts @itsrainingmani ?

@itsrainingmani
Copy link
Contributor Author

Yeah no problem

tomisme and others added 3 commits July 8, 2020 16:36
…decompose monolith block-el (athensresearch#232)

* line 524 of blocks. if I use a dispatch, on-drag-end doesn't get called

* feat(blocks): drag and drop PoC for local event handlers. refactor block-el
@itsrainingmani
Copy link
Contributor Author

@tangjeff0 Should be able to merge now.

Copy link
Collaborator

@tangjeff0 tangjeff0 left a comment

Choose a reason for hiding this comment

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

Great job!!!!!!!!!

@itsrainingmani
Copy link
Contributor Author

Thanks !!

korlaism pushed a commit to korlaism/athens that referenced this pull request Jul 19, 2021
…ent` and `unindent` when already a top-level child (athensresearch#228)

* fix(blocks): prevent unindent when already a top-level child in current context (athensresearch#209)

If the node being unindented is the top-level node in the current context, prevent unindent by checking if parent node id is equal to id present in :current-route object.

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>

* fix(blocks): prevent indent when already a leaf block (athensresearch#209)

A leaf block is a block with block order 0. If the block order is 0, do not indent and return a no-op in the indent event handler

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>

* fix: prevent default browser behavior for tab and shift+tab when there is no indent or unindent happening (athensresearch#209)

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>

* fix(blocks) - Refactor indent and unindent event handlers

* Move the block zero check in indent event handler to the on-key-down handler since it doesn't require any re-frame or datascript subscriptions
* Rename context-root to context-root-uid and remove unnecessary comment in unindent event handler
* Use the stricter parent ID to context-root uid check instead of (and parent grandpa) in unindent event handler

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>

* Add missing devtool devcard deps (athensresearch#229)

* feat(blocks): Drag n drop v2. use local listeners instead of global. decompose monolith block-el (athensresearch#232)

* line 524 of blocks. if I use a dispatch, on-drag-end doesn't get called

* feat(blocks): drag and drop PoC for local event handlers. refactor block-el

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
Co-authored-by: Tom H <git@tomisme.com>
Co-authored-by: jeff <tangj1122@gmail.com>
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.

None yet

4 participants