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

[frontend] fix bad behaviour onBlur Markdown fields (#5943) #6035

Merged
merged 2 commits into from
Feb 26, 2024
Merged

Conversation

frapuks
Copy link
Member

@frapuks frapuks commented Feb 19, 2024

Proposed changes

  • Fix bad behaviour for saving Markdown fields
  • Text is not saved when a Markdown formatting button is clicked (Heading, Bold...).
  • Text is saved when the field is defocused, with Makdown formatting.
  • Saving even when the field is defocused by focusing another Markdown or TextArea field

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

  • A good example form is on page : Techniques / Courses of Actions / select one / update

For testing

  • Update description text (write "test" for example)
  • click on title button => Expected : Markdown form field content is updating ("### test"), but not description on overview / details / description
  • click outside Markdown field => Expected : saving description, and display on overview / details / description
  • try the same, when clicking outside, try focusing other form input, other markdown field (Threat hunting techniques), other textarea field (Log sources), etc => Expected : saving description, and display on overview / details / description

@frapuks frapuks added the filigran team use to identify PR from the Filigran team label Feb 19, 2024
@frapuks frapuks self-assigned this Feb 19, 2024
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.74%. Comparing base (18c4db8) to head (952b6bd).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6035      +/-   ##
==========================================
+ Coverage   66.72%   66.74%   +0.01%     
==========================================
  Files         540      540              
  Lines       64180    64180              
  Branches     5240     5242       +2     
==========================================
+ Hits        42827    42834       +7     
+ Misses      21353    21346       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JeremyCloarec
Copy link
Contributor

JeremyCloarec commented Feb 19, 2024

There is a small edge case when the bug still occurs.
You filter the markdown button click to prevent the field from saving when applying markdown, which works. But we still want to save the text when focusing on the markdown button of the other Markdown field.
I can do a screen share if what I explained isn't clear

@frapuks
Copy link
Member Author

frapuks commented Feb 23, 2024

There is a small edge case when the bug still occurs. You filter the markdown button click to prevent the field from saving when applying markdown, which works. But we still want to save the text when focusing on the markdown button of the other Markdown field. I can do a screen share if what I explained isn't clear

Fix with refactoring condition :

  • Before : check if the html node is INPUT, DIV, BUTTON, UNDEFINED, TEXTAREA (with other conditions if it's Textaera).
  • Now : check only if click is inside or outside MardkownField.

it works if you click on markdown format button of current markdown field => the click in considered inside => no saving, continue to edit the same field
It works even if you click on markdown format button in othe markdown field => the click is outside => saving the current field on blur, and focus the new markdown field

@frapuks frapuks marked this pull request as ready for review February 23, 2024 10:19
Copy link
Contributor

@JeremyCloarec JeremyCloarec left a comment

Choose a reason for hiding this comment

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

Tested OK

@frapuks frapuks merged commit aceeeed into master Feb 26, 2024
8 checks passed
@frapuks frapuks deleted the issue/5943 branch February 26, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown in rich text fields is reverted when first applied
2 participants