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

rendered_markdown: Fix code getting copied when visiting custom playground. #29865

Merged
merged 1 commit into from May 6, 2024

Conversation

nimishmedatwal
Copy link
Collaborator

@nimishmedatwal nimishmedatwal commented Apr 26, 2024

This pr fixes code getting copied even when View in xxx playground is clicked.

Fixes: #29844.

Screenshots and screen captures:

Before After
Animation10 Animation11
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@zulipbot zulipbot added size: S area: message feed (UI) Buttons/UI directly in the message feed (not popovers, etc.) bug priority: high labels Apr 26, 2024
@nimishmedatwal
Copy link
Collaborator Author

nimishmedatwal commented Apr 27, 2024

I am not sure if this test (and tests like this) in rendered_markdown.test.js needs to be changed since all the node-tests are passing.

run_test("code playground none", ({override, mock_template}) => {
    override(realm_playground, "get_playground_info_for_languages", (language) => {
        assert.equal(language, "javascript");
        return undefined;
    });

    override(copied_tooltip, "show_copied_confirmation", noop);

    const {prepends, $button_container, $view_code} = test_code_playground(mock_template, false);
    assert.deepEqual(prepends, [$button_container]);
    assert_clipboard_setup();

    assert.equal($view_code.attr("data-tippy-content"), undefined);
    assert.equal($view_code.attr("aria-label"), undefined);
});

@alya
Copy link
Contributor

alya commented Apr 30, 2024

@amanagr are you up for reviewing this one? I haven't tested.

@alya alya added the maintainer review PR is ready for review by Zulip maintainers. label Apr 30, 2024
@amanagr
Copy link
Member

amanagr commented May 6, 2024

LGTM

@amanagr amanagr added integration review Added by maintainers when a PR may be ready for integration. and removed maintainer review PR is ready for review by Zulip maintainers. labels May 6, 2024
@timabbott timabbott merged commit acf13e4 into zulip:main May 6, 2024
7 checks passed
@timabbott
Copy link
Sponsor Member

Merged, thanks @nimishmedatwal!

@timabbott
Copy link
Sponsor Member

I guess @karlstolley FYI; this is a case where brittle JS made refactoring the HTML structure break stuff. I don't think there's an easy way to catch this sort of thing except experimentally, so I wouldn't spend undue additional time on refactoring. I don't think this type of bad pattern is common.

I guess we didn't fix the brittleness in this PR. @nimishmedatwal would you put up a follow-up that instead uses .closest() and .find() to find the right element without making assumptions about how many containing elements there are?

@nimishmedatwal
Copy link
Collaborator Author

I guess we didn't fix the brittleness in this PR. @nimishmedatwal would you put up a follow-up that instead uses .closest() and .find() to find the right element without making assumptions about how many containing elements there are?

Sure! I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: message feed (UI) Buttons/UI directly in the message feed (not popovers, etc.) bug integration review Added by maintainers when a PR may be ready for integration. priority: high size: S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix incorrect "Copied" notice when visiting a custom playground
5 participants