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

Several link handling fixes #5422

Merged
merged 7 commits into from
Mar 1, 2024
Merged

Several link handling fixes #5422

merged 7 commits into from
Mar 1, 2024

Conversation

mejo-
Copy link
Member

@mejo- mejo- commented Feb 28, 2024

📝 Summary

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

No longer hide the link bubble when editor looses focus. We just always
show the link bubble as long as the selection stays within a link or
until it's manually closed.

This eliminates possible race-conditions and corner-case bugs.

Signed-off-by: Jonas <[email protected]>
Prevents annoying race conditions when testing the LinkBubble in
Cypress.

Signed-off-by: Jonas <[email protected]>
Full URLs have the advantage that they also work when clicking them
outside the Nextcloud context, e.g. in a local markdown editor.

Their main disadvantage is that they cause trouble on Nextcloud
instances with more than one hostname or after changing the hostname of
a Nextcloud instance.

The first use case (opening a file outside Nextcloud context) is more
likely and less of a corner case than the second (changing hostname), so
we decided to go for full URLs.

Signed-off-by: Jonas <[email protected]>
Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

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

Looks good .. just one concern

this.#updateDebounceTimer = window.setTimeout(() => {
this.updateFromSelection(view)
}, updateDelay)
debounce(() => this.updateFromSelection.bind(this)(view), updateDelay, { immediate: true })
Copy link
Member

Choose a reason for hiding this comment

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

Does this debounce actually have an effect? As far as I know it would still call every time, unless you would call the returned function

Copy link
Member Author

Choose a reason for hiding this comment

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

@max-nextcloud to the rescue 😬 I still struggle to understand the different scopes of JS functions 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah sorry, now I got what you mean. Indeed, debounce just returns a function that needs to be called. I thought it would be about the scope of this in updateFromSelection(). Anyways, should be fixed now ☺️

Run `updateFromSelection()` immediately on first call and only delay
further runs.

This fixes a race condition with `this.#hadUpdateFromClick` which gets
set when updating from click and gets cleaned up after 200ms.

Fixes an issue with the bubble disappearing immediately when clicking on
a link after unfocussed browser and editor.

Signed-off-by: Jonas <[email protected]>
Required to allow relative links (and those without origin) to other
collectives pages to be resolved by link previews.

Signed-off-by: Jonas <[email protected]>
@mejo-
Copy link
Member Author

mejo- commented Feb 29, 2024

Cypress tests also green now 😊

@mejo-
Copy link
Member Author

mejo- commented Mar 1, 2024

Commit "fix(ActionInsertLink): Sync NcActionInput value property" should get backported to stable28, probably also to stable27.

@juliushaertl juliushaertl merged commit f34d060 into main Mar 1, 2024
58 checks passed
@juliushaertl juliushaertl deleted the fix/link_handling2 branch March 1, 2024 09:48
@juliushaertl
Copy link
Member

/backport 0dd249c to stable28

@juliushaertl
Copy link
Member

/backport 0dd249c to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Link to website" entry keeps resetting when trying to add/change link mailto links are not possible
2 participants