kintone-samples/plugin-samples

[conditionformat2] Plug-in stops working if Date is null

will-yama opened this issue · 1 comments

If a Date field is placed in the Text Format conditions settings, and the date inside a record has no value, the plug-in stops coloring in any cells that come after that field.

Bug Replication

  1. Create an App with a Date field and a Text field
  2. Set the Conditional Format plug-in, with the below settings

Text Format Condition

Field with condition Condition Value Field to Format Font Color Background Color Font Size Style
Date = 2018-09-14 Date #2500FF #FF0000 Normal Normal
Text = test Text #2500FF #FF0000 Normal Normal

Save the settings and update the App.

  1. Add a record into the App.
    Place no value inside the Date field.
    Place the value test into the Text field

  2. After saving, view the Record Details page or the Record List page.

What should happen

Date field is not styled (as the condition does not match).
Text field is styled with blue text and red background.

What actually happens

Date field is not styled.
Text field is also not styled.
An error appears in the console:

"Uncaught TypeError: Cannot read property 'match' of null"

conditonal_format_bug

Thoughts

There is an if statement in desktop.js that compares the "field" variable, but this field variable will have no properties if it is null. Probably needs to check if the value is null first before going into this statement.

https://github.com/kintone/plugin-examples/blob/b4b3dc28c502f3d398397d2958b50e1d0af1dd9f/examples/conditionformat2/js/desktop.js#L152

Fixed with #138