Developer builds calorie lookup table, uncovers accidental duplicate filter logic
A developer created a lightweight, no-login calorie reference tool that lets users search common foods and see calorie counts instantly. The tool uses a Vue computed property that filters food data across four fields — Chinese name, English name, and both language versions of the category — which unintentionally made the text search box behave like a category filter. Typing a word like 'fruit' into the search box returns all fruits, duplicating the function of the separate category dropdown. The developer also noted that storing calorie values as strings rather than numbers works for now but will cause incorrect sorting if a sort-by-calories feature is ever added. Additionally, the table renders food data twice in HTML — once as a hidden semantic table for screen readers and search engines, and once as a visible CSS grid for interactive features like click-to-copy and mobile reflow.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in