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(RichTextEditor): flyout modals not closing when clicked outside #1732

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

SamCreasey
Copy link
Contributor

@SamCreasey SamCreasey commented Mar 5, 2024

Fixes an issue where toolbar flyouts would remain open when the user clicked a different spot inside the RichTextEditor.
Also reduces the number of calls and the complexity of the blur observer by only activating it when the editor is in focus.

Linked pr: Frontify/brand-sdk#803

How to test with a guideline-block:
To be sure that you are using local code add a console.log() to the RTE component. (It will only show in edit mode since view mode uses the serialized html)

In @frontify/fondue

pnpm link --global
pnpm build

In @frontify/brand-sdk

rm -rf node_modules/.vite && rm -rf packages/guideline-blocks-settings/node_modules/.vite && pnpm build 
cd packages/guideline-blocks-settings
pnpm link --global
cd ../app-bridge
pnpm link --global

In @frontify/guideline-blocks

cd packages/text-block
pnpm i --frozen-lockfile
pnpm link --global @frontify/fondue @frontify/app-bridge @frontify/guideline-blocks-settings
rm -rf node_modules/.vite && pnpm serve

Copy link

changeset-bot bot commented Mar 5, 2024

🦋 Changeset detected

Latest commit: 01399a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@frontify/fondue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Mar 5, 2024

Deploy Preview for fondue-components ready!

Name Link
🔨 Latest commit 01399a1
🔍 Latest deploy log https://app.netlify.com/sites/fondue-components/deploys/65e6c03df729ce0007645c07
😎 Deploy Preview https://deploy-preview-1732--fondue-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Mar 5, 2024

Deploy Preview for beta-fondue-components ready!

Name Link
🔨 Latest commit 01399a1
🔍 Latest deploy log https://app.netlify.com/sites/beta-fondue-components/deploys/65e6c03dd19a5a00084ff679
😎 Deploy Preview https://deploy-preview-1732--beta-fondue-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@SamCreasey SamCreasey requested a review from fulopdaniel March 5, 2024 07:43
setIsBlurObserverActive(true);
};

richTextEditor.addEventListener('focusin', setupBlurObserver);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we unsubscribe on focusout? Otherwise click in => click out => click in will have 2 listeners for the same thing, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

click out should always trigger the unsubscribe from the hook above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding the focusout handler means repeating a lot of the conditional checks that are already prevent in the document event listener (check if its in a modal or the toolbar etc). It seems like it would make sense for it to unsubscribe itself

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah my bad

@SamCreasey SamCreasey requested a review from fulopdaniel March 5, 2024 09:31
@SamCreasey SamCreasey merged commit 7acb645 into main Mar 5, 2024
24 checks passed
@SamCreasey SamCreasey deleted the feat/floating-modal-wrapper branch March 5, 2024 09:38
Copy link
Contributor

github-actions bot commented Mar 5, 2024

Lead time: 3 hours, 1 minutes, 32 seconds (3.03 total hours) from first commit to close.
Review time: 2 hours, 50 minutes, 12 seconds (2.84 total hours) from ready for review to close.

  • First commit: 5.3.2024, 07:37:07.
  • Ready for review: 5.3.2024, 07:48:27.
  • Closed: 5.3.2024, 10:38:39.

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